Skip to content

Commit

Permalink
Fix multipart upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Dec 14, 2023
1 parent 8c9452a commit 09ba3ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 5 additions & 3 deletions node-src/lib/uploadFiles.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import retry from 'async-retry';
import { filesize } from 'filesize';
import FormData from 'form-data';
import { createReadStream } from 'fs';
import pLimit from 'p-limit';
import progress from 'progress-stream';
import { Context, FileDesc, TargetInfo } from '../types';
import { FormData } from 'node-fetch';
import { filesize } from 'filesize';

export async function uploadFiles(
ctx: Context,
Expand Down Expand Up @@ -38,7 +38,9 @@ export async function uploadFiles(

const formData = new FormData();
Object.entries(formFields).forEach(([k, v]) => formData.append(k, v));
formData.append('file', createReadStream(localPath).pipe(progressStream)); // must be the last one
formData.append('file', createReadStream(localPath).pipe(progressStream), {
knownLength: contentLength,
});

const res = await ctx.http.fetch(
formAction,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
"execa": "^7.2.0",
"fake-tag": "^2.0.0",
"filesize": "^10.1.0",
"form-data": "^4.0.0",
"fs-extra": "^10.0.0",
"https-proxy-agent": "^7.0.2",
"husky": "^7.0.0",
Expand Down
9 changes: 9 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7893,6 +7893,15 @@ form-data@^3.0.0:
combined-stream "^1.0.8"
mime-types "^2.1.12"

form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"

format@^0.2.0:
version "0.2.2"
resolved "https://registry.yarnpkg.com/format/-/format-0.2.2.tgz#d6170107e9efdc4ed30c9dc39016df942b5cb58b"
Expand Down

0 comments on commit 09ba3ac

Please sign in to comment.