From c0942596652eab5c16a138a3c85c865d9ae89fd9 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 11 Apr 2024 15:40:07 +0200 Subject: [PATCH 1/2] @uppy/aws-s3: default to multipart depending on the size of input --- packages/@uppy/aws-s3/src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@uppy/aws-s3/src/index.ts b/packages/@uppy/aws-s3/src/index.ts index 4b84221489..47e8358649 100644 --- a/packages/@uppy/aws-s3/src/index.ts +++ b/packages/@uppy/aws-s3/src/index.ts @@ -280,10 +280,10 @@ const defaultOptions = { allowedMetaFields: true, limit: 6, getTemporarySecurityCredentials: false as any, - shouldUseMultipart: ((file: UppyFile) => - file.size !== 0) as any as true, // TODO: Switch default to: // eslint-disable-next-line no-bitwise - // shouldUseMultipart: (file) => file.size >> 10 >> 10 > 100, + shouldUseMultipart: ((file: UppyFile) => + // eslint-disable-next-line no-bitwise + (file.size! >> 10) >> 10 > 100) as any as true, retryDelays: [0, 1000, 3000, 5000], companionHeaders: {}, } satisfies Partial> From a0052dc8ca15d9c059d3a11f80016e023423b636 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 11 Apr 2024 18:35:23 +0200 Subject: [PATCH 2/2] fixup --- packages/@uppy/aws-s3/src/index.test.ts | 7 +++++++ packages/@uppy/aws-s3/src/index.ts | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/@uppy/aws-s3/src/index.test.ts b/packages/@uppy/aws-s3/src/index.test.ts index bddbc19923..fb68c8ef1e 100644 --- a/packages/@uppy/aws-s3/src/index.test.ts +++ b/packages/@uppy/aws-s3/src/index.test.ts @@ -108,6 +108,7 @@ describe('AwsS3Multipart', () => { beforeEach(() => { core = new Core() core.use(AwsS3Multipart, { + shouldUseMultipart: true, limit: 0, createMultipartUpload: vi.fn(() => { return { @@ -167,6 +168,7 @@ describe('AwsS3Multipart', () => { let busySpy let doneSpy awsS3Multipart.setOptions({ + shouldUseMultipart: true, retryDelays: [10], createMultipartUpload: vi.fn((file) => { // @ts-expect-error protected property @@ -250,6 +252,7 @@ describe('AwsS3Multipart', () => { it('retries uploadPartBytes when it fails once', async () => { const core = new Core().use(AwsS3Multipart, { + shouldUseMultipart: true, createMultipartUpload, completeMultipartUpload: vi.fn(async () => ({ location: 'test' })), abortMultipartUpload: vi.fn(() => { @@ -282,6 +285,7 @@ describe('AwsS3Multipart', () => { it('calls `upload-error` when uploadPartBytes fails after all retries', async () => { const core = new Core().use(AwsS3Multipart, { + shouldUseMultipart: true, retryDelays: [10], createMultipartUpload, completeMultipartUpload: vi.fn(async () => ({ location: 'test' })), @@ -451,6 +455,7 @@ describe('AwsS3Multipart', () => { it('preserves file metadata if upload is completed', async () => { core = new Core().use(AwsS3Multipart, { + shouldUseMultipart: true, createMultipartUpload, signPart, listParts, @@ -511,6 +516,7 @@ describe('AwsS3Multipart', () => { }) core = new Core().use(AwsS3Multipart, { + shouldUseMultipart: true, createMultipartUpload, signPart: signPartWithAbort, listParts, @@ -580,6 +586,7 @@ describe('AwsS3Multipart', () => { }) core = new Core().use(AwsS3Multipart, { + shouldUseMultipart: true, createMultipartUpload, signPart: signPartWithPause, listParts, diff --git a/packages/@uppy/aws-s3/src/index.ts b/packages/@uppy/aws-s3/src/index.ts index 47e8358649..1c319a3008 100644 --- a/packages/@uppy/aws-s3/src/index.ts +++ b/packages/@uppy/aws-s3/src/index.ts @@ -337,8 +337,6 @@ export default class AwsS3Multipart< // We need the `as any` here because of the dynamic default options. this.type = 'uploader' this.id = this.opts.id || 'AwsS3Multipart' - // @ts-expect-error TODO: remove unused - this.title = 'AWS S3 Multipart' // TODO: only initiate `RequestClient` is `companionUrl` is defined. this.#client = new RequestClient(uppy, opts as any)