Skip to content

Commit

Permalink
chore: remove form-data dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Feb 3, 2024
1 parent b768eef commit 8330069
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4

- name: Run setup typescript-sdk
run: npm ci && npm run build
working-directory: ./open-api/typescript-sdk
Expand Down Expand Up @@ -143,6 +146,9 @@ jobs:
with:
submodules: "recursive"

- name: Setup Node
uses: actions/setup-node@v4

- name: Run setup typescript-sdk
run: npm ci && npm run build
working-directory: ./open-api/typescript-sdk
Expand Down
13 changes: 6 additions & 7 deletions cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"byte-size": "^8.1.1",
"cli-progress": "^3.12.0",
"commander": "^11.0.0",
"form-data": "^4.0.0",
"glob": "^10.3.1",
"yaml": "^2.3.1"
},
Expand Down Expand Up @@ -58,5 +57,8 @@
"type": "git",
"url": "github:immich-app/immich",
"directory": "cli"
},
"engines": {
"node": ">=20.0.0"
}
}
10 changes: 4 additions & 6 deletions cli/src/commands/upload.command.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8330069

Please sign in to comment.