mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:27:09 -05:00 
			
		
		
		
	fix(cli): upload large file with openAPI api (#5246)
* fix(cli): upload large file with openAPI * function name * fix: use boolean false * chore: version bump * fix: package-lock version --------- Co-authored-by: Jonathan Jogenfors <jonathan@jogenfors.se>
This commit is contained in:
		
							parent
							
								
									af1113bf9e
								
							
						
					
					
						commit
						8ff4a08a2c
					
				
							
								
								
									
										4
									
								
								cli/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								cli/package-lock.json
									
									
									
										generated
									
									
									
								
							@ -1,12 +1,12 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "@immich/cli",
 | 
					  "name": "@immich/cli",
 | 
				
			||||||
  "version": "2.0.3",
 | 
					  "version": "2.0.4",
 | 
				
			||||||
  "lockfileVersion": 2,
 | 
					  "lockfileVersion": 2,
 | 
				
			||||||
  "requires": true,
 | 
					  "requires": true,
 | 
				
			||||||
  "packages": {
 | 
					  "packages": {
 | 
				
			||||||
    "": {
 | 
					    "": {
 | 
				
			||||||
      "name": "@immich/cli",
 | 
					      "name": "@immich/cli",
 | 
				
			||||||
      "version": "2.0.3",
 | 
					      "version": "2.0.4",
 | 
				
			||||||
      "license": "MIT",
 | 
					      "license": "MIT",
 | 
				
			||||||
      "dependencies": {
 | 
					      "dependencies": {
 | 
				
			||||||
        "axios": "^1.6.2",
 | 
					        "axios": "^1.6.2",
 | 
				
			||||||
 | 
				
			|||||||
@ -1,12 +1,16 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "@immich/cli",
 | 
					  "name": "@immich/cli",
 | 
				
			||||||
  "version": "2.0.3",
 | 
					  "version": "2.0.4",
 | 
				
			||||||
  "description": "Command Line Interface (CLI) for Immich",
 | 
					  "description": "Command Line Interface (CLI) for Immich",
 | 
				
			||||||
  "main": "dist/index.js",
 | 
					  "main": "dist/index.js",
 | 
				
			||||||
  "bin": {
 | 
					  "bin": {
 | 
				
			||||||
    "immich": "./dist/src/index.js"
 | 
					    "immich": "./dist/src/index.js"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "license": "MIT",
 | 
					  "license": "MIT",
 | 
				
			||||||
 | 
					  "keywords": [
 | 
				
			||||||
 | 
					    "immich",
 | 
				
			||||||
 | 
					    "cli"
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "axios": "^1.6.2",
 | 
					    "axios": "^1.6.2",
 | 
				
			||||||
    "byte-size": "^8.1.1",
 | 
					    "byte-size": "^8.1.1",
 | 
				
			||||||
@ -77,7 +81,7 @@
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  "repository": {
 | 
					  "repository": {
 | 
				
			||||||
    "type": "git",
 | 
					    "type": "git",
 | 
				
			||||||
    "url": "git+https://github.com/immich-app/immich.git",
 | 
					    "url": "github:immich-app/immich",
 | 
				
			||||||
    "directory": "cli"
 | 
					    "directory": "cli"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,7 @@ import {
 | 
				
			|||||||
  UserApi,
 | 
					  UserApi,
 | 
				
			||||||
} from './open-api';
 | 
					} from './open-api';
 | 
				
			||||||
import { ApiConfiguration } from '../cores/api-configuration';
 | 
					import { ApiConfiguration } from '../cores/api-configuration';
 | 
				
			||||||
 | 
					import FormData from 'form-data';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class ImmichApi {
 | 
					export class ImmichApi {
 | 
				
			||||||
  public userApi: UserApi;
 | 
					  public userApi: UserApi;
 | 
				
			||||||
@ -35,6 +36,7 @@ export class ImmichApi {
 | 
				
			|||||||
          'x-api-key': apiKey,
 | 
					          'x-api-key': apiKey,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
 | 
					      formDataCtor: FormData,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.userApi = new UserApi(this.config);
 | 
					    this.userApi = new UserApi(this.config);
 | 
				
			||||||
 | 
				
			|||||||
@ -8,11 +8,11 @@ export class Asset {
 | 
				
			|||||||
  readonly path: string;
 | 
					  readonly path: string;
 | 
				
			||||||
  readonly deviceId!: string;
 | 
					  readonly deviceId!: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  assetData?: File;
 | 
					  assetData?: fs.ReadStream;
 | 
				
			||||||
  deviceAssetId?: string;
 | 
					  deviceAssetId?: string;
 | 
				
			||||||
  fileCreatedAt?: string;
 | 
					  fileCreatedAt?: string;
 | 
				
			||||||
  fileModifiedAt?: string;
 | 
					  fileModifiedAt?: string;
 | 
				
			||||||
  sidecarData?: File;
 | 
					  sidecarData?: fs.ReadStream;
 | 
				
			||||||
  sidecarPath?: string;
 | 
					  sidecarPath?: string;
 | 
				
			||||||
  fileSize!: number;
 | 
					  fileSize!: number;
 | 
				
			||||||
  albumName?: string;
 | 
					  albumName?: string;
 | 
				
			||||||
@ -30,13 +30,13 @@ export class Asset {
 | 
				
			|||||||
    this.fileSize = stats.size;
 | 
					    this.fileSize = stats.size;
 | 
				
			||||||
    this.albumName = this.extractAlbumName();
 | 
					    this.albumName = this.extractAlbumName();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.assetData = await this.getFileObject(this.path);
 | 
					    this.assetData = this.getReadStream(this.path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // TODO: doesn't xmp replace the file extension? Will need investigation
 | 
					    // TODO: doesn't xmp replace the file extension? Will need investigation
 | 
				
			||||||
    const sideCarPath = `${this.path}.xmp`;
 | 
					    const sideCarPath = `${this.path}.xmp`;
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      fs.accessSync(sideCarPath, fs.constants.R_OK);
 | 
					      fs.accessSync(sideCarPath, fs.constants.R_OK);
 | 
				
			||||||
      this.sidecarData = await this.getFileObject(sideCarPath);
 | 
					      this.sidecarData = this.getReadStream(sideCarPath);
 | 
				
			||||||
    } catch (error) {}
 | 
					    } catch (error) {}
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -48,19 +48,18 @@ export class Asset {
 | 
				
			|||||||
    if (!this.deviceId) throw new Error('Device id not set');
 | 
					    if (!this.deviceId) throw new Error('Device id not set');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
      assetData: this.assetData,
 | 
					      assetData: this.assetData as any,
 | 
				
			||||||
      deviceAssetId: this.deviceAssetId,
 | 
					      deviceAssetId: this.deviceAssetId,
 | 
				
			||||||
      deviceId: this.deviceId,
 | 
					      deviceId: this.deviceId,
 | 
				
			||||||
      fileCreatedAt: this.fileCreatedAt,
 | 
					      fileCreatedAt: this.fileCreatedAt,
 | 
				
			||||||
      fileModifiedAt: this.fileModifiedAt,
 | 
					      fileModifiedAt: this.fileModifiedAt,
 | 
				
			||||||
      isFavorite: false,
 | 
					      isFavorite: false,
 | 
				
			||||||
      sidecarData: this.sidecarData,
 | 
					      sidecarData: this.sidecarData as any,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private async getFileObject(path: string): Promise<File> {
 | 
					  private getReadStream(path: string): fs.ReadStream {
 | 
				
			||||||
    const buffer = await fs.promises.readFile(path);
 | 
					    return fs.createReadStream(path);
 | 
				
			||||||
    return new File([buffer], basename(path));
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  async delete(): Promise<void> {
 | 
					  async delete(): Promise<void> {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user