chore: remove form-data dependency (#6876)

chore: remove form-data dependency
This commit is contained in:
Ben McCann 2024-02-02 21:44:53 -08:00 committed by GitHub
parent 79d3342c3d
commit a4cfb51df5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 14 deletions

View file

@ -1,8 +1,7 @@
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
import byteSize from 'byte-size';
import cliProgress from 'cli-progress';
import FormData from 'form-data';
import fs, { ReadStream, createReadStream } from 'node:fs';
import fs, { createReadStream } from 'node:fs';
import { CrawlService } from '../services/crawl.service';
import { BaseCommand } from './base-command';
import { basename } from 'node:path';
@ -47,14 +46,14 @@ class Asset {
// TODO: doesn't xmp replace the file extension? Will need investigation
const sideCarPath = `${this.path}.xmp`;
let sidecarData: ReadStream | undefined = undefined;
let sidecarData: Blob | undefined = undefined;
try {
await access(sideCarPath, constants.R_OK);
sidecarData = createReadStream(sideCarPath);
sidecarData = new File([await fs.openAsBlob(sideCarPath)], basename(sideCarPath));
} catch {}
const data: any = {
assetData: createReadStream(this.path),
assetData: new File([await fs.openAsBlob(this.path)], basename(this.path)),
deviceAssetId: this.deviceAssetId,
deviceId: 'CLI',
fileCreatedAt: this.fileCreatedAt,
@ -269,7 +268,6 @@ export class UploadCommand extends BaseCommand {
url,
headers: {
'x-api-key': this.immichApi.apiKey,
...data.getHeaders(),
},
maxContentLength: Number.POSITIVE_INFINITY,
maxBodyLength: Number.POSITIVE_INFINITY,