From 7e4608b34f7fa1fc2ac2ae972d7904bce6a29275 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 2 Feb 2023 12:28:46 +0100 Subject: [PATCH 1/3] @uppy/aws-s3: add `shouldUseMultipart` option --- packages/@uppy/aws-s3/package.json | 1 + packages/@uppy/aws-s3/src/index.js | 5 +++++ packages/@uppy/aws-s3/types/index.d.ts | 10 +++------- yarn.lock | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/@uppy/aws-s3/package.json b/packages/@uppy/aws-s3/package.json index 315bcac4f4..3e073d745a 100644 --- a/packages/@uppy/aws-s3/package.json +++ b/packages/@uppy/aws-s3/package.json @@ -23,6 +23,7 @@ "url": "git+https://github.com/transloadit/uppy.git" }, "dependencies": { + "@uppy/aws-s3-multipart": "workspace:^", "@uppy/companion-client": "workspace:^", "@uppy/utils": "workspace:^", "@uppy/xhr-upload": "workspace:^", diff --git a/packages/@uppy/aws-s3/src/index.js b/packages/@uppy/aws-s3/src/index.js index cb0c267f7a..37bf2518e9 100644 --- a/packages/@uppy/aws-s3/src/index.js +++ b/packages/@uppy/aws-s3/src/index.js @@ -26,6 +26,7 @@ */ import BasePlugin from '@uppy/core/lib/BasePlugin.js' +import AwsS3Multipart from '@uppy/aws-s3-multipart' import { RateLimitedQueue, internalRateLimitedQueue } from '@uppy/utils/lib/RateLimitedQueue' import { RequestClient } from '@uppy/companion-client' import { filterNonFailedFiles, filterFilesToEmitUploadStarted } from '@uppy/utils/lib/fileFilters' @@ -111,6 +112,9 @@ export default class AwsS3 extends BasePlugin { #uploader constructor (uppy, opts) { + if (opts?.shouldUseMultipart != null && opts.shouldUseMultipart !== false) { + return new AwsS3Multipart(uppy, opts) + } super(uppy, opts) this.type = 'uploader' this.id = this.opts.id || 'AwsS3' @@ -123,6 +127,7 @@ export default class AwsS3 extends BasePlugin { limit: 0, allowedMetaFields: [], // have to opt in getUploadParameters: this.getUploadParameters.bind(this), + shouldUseMultipart: false, companionHeaders: {}, } diff --git a/packages/@uppy/aws-s3/types/index.d.ts b/packages/@uppy/aws-s3/types/index.d.ts index e14d13c18a..4f5bd25288 100644 --- a/packages/@uppy/aws-s3/types/index.d.ts +++ b/packages/@uppy/aws-s3/types/index.d.ts @@ -1,4 +1,5 @@ -import type { PluginOptions, BasePlugin, UppyFile } from '@uppy/core' +import { AwsS3MultipartOptions } from '@uppy/aws-s3-multipart' +import type { BasePlugin } from '@uppy/core' type MaybePromise = T | Promise @@ -9,14 +10,9 @@ export interface AwsS3UploadParameters { headers?: { [type: string]: string } } -export interface AwsS3Options extends PluginOptions { - companionHeaders?: { [type: string]: string } - companionUrl?: string - getUploadParameters?: (file: UppyFile) => MaybePromise - allowedMetaFields?: string[] | null +export interface AwsS3Options extends AwsS3MultipartOptions { /** @deprecated future versions of this plugin will use the Expires value from the backend */ timeout?: number - limit?: number } declare class AwsS3 extends BasePlugin {} diff --git a/yarn.lock b/yarn.lock index d661ee4b82..1122159294 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9316,6 +9316,7 @@ __metadata: resolution: "@uppy/aws-s3@workspace:packages/@uppy/aws-s3" dependencies: "@jest/globals": ^29.0.0 + "@uppy/aws-s3-multipart": "workspace:^" "@uppy/companion-client": "workspace:^" "@uppy/utils": "workspace:^" "@uppy/xhr-upload": "workspace:^" From 28276f8cf7a0dfe3269107cb00b2d59e0db51cad Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Tue, 2 May 2023 21:38:02 +0100 Subject: [PATCH 2/3] add getUploadParameters --- packages/@uppy/aws-s3-multipart/types/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/@uppy/aws-s3-multipart/types/index.d.ts b/packages/@uppy/aws-s3-multipart/types/index.d.ts index 5a68b24c3d..de63f3a430 100644 --- a/packages/@uppy/aws-s3-multipart/types/index.d.ts +++ b/packages/@uppy/aws-s3-multipart/types/index.d.ts @@ -45,6 +45,9 @@ export interface AwsS3MultipartOptions extends PluginOptions { limit?: number shouldUseMultipart?: boolean | ((file: UppyFile) => boolean) retryDelays?: number[] | null + getUploadParameters?: ( + file: UppyFile + ) => MaybePromise<{ url: string }> } declare class AwsS3Multipart extends BasePlugin< From 6b3af41ef059fc366e22682dc0cb89bc71c20d71 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 24 May 2023 15:05:35 +0200 Subject: [PATCH 3/3] Update packages/@uppy/aws-s3/src/index.js --- packages/@uppy/aws-s3/src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/@uppy/aws-s3/src/index.js b/packages/@uppy/aws-s3/src/index.js index 6133a70f8c..3a425ede77 100644 --- a/packages/@uppy/aws-s3/src/index.js +++ b/packages/@uppy/aws-s3/src/index.js @@ -113,7 +113,8 @@ export default class AwsS3 extends BasePlugin { #uploader constructor (uppy, opts) { - if (opts?.shouldUseMultipart != null && opts.shouldUseMultipart !== false) { + // Opt-in to using the multipart plugin, which is going to be the only S3 plugin as of the next semver. + if (opts?.shouldUseMultipart != null) { return new AwsS3Multipart(uppy, opts) } super(uppy, opts)