Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uppy/aws-s3: add shouldUseMultipart option #4299

Merged
merged 4 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/@uppy/aws-s3-multipart/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/aws-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:^",
Expand Down
6 changes: 6 additions & 0 deletions packages/@uppy/aws-s3/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -112,6 +113,10 @@ export default class AwsS3 extends BasePlugin {
#uploader

constructor (uppy, opts) {
// 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)
this.type = 'uploader'
this.id = this.opts.id || 'AwsS3'
Expand All @@ -124,6 +129,7 @@ export default class AwsS3 extends BasePlugin {
limit: 0,
allowedMetaFields: [], // have to opt in
getUploadParameters: this.getUploadParameters.bind(this),
shouldUseMultipart: false,
companionHeaders: {},
}

Expand Down
10 changes: 3 additions & 7 deletions packages/@uppy/aws-s3/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -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> = T | Promise<T>

Expand All @@ -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<AwsS3UploadParameters>
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<AwsS3Options> {}
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:^"
Expand Down