mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-23 02:08:30 +00:00
s3: Respect limit option for upload parameter requests too
Ref https://github.com/transloadit/uppy/issues/513 Apply the same limit to upload parameter requests as is applied to XHRUpload requests.
This commit is contained in:
parent
a5085fba9a
commit
fa8bb48c50
1 changed files with 10 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
const Plugin = require('../../core/Plugin')
|
||||
const Translator = require('../../core/Translator')
|
||||
const { limitPromises } = require('../../core/Utils')
|
||||
const XHRUpload = require('../XHRUpload')
|
||||
|
||||
function isXml (xhr) {
|
||||
|
|
@ -34,6 +35,12 @@ module.exports = class AwsS3 extends Plugin {
|
|||
this.i18n = this.translator.translate.bind(this.translator)
|
||||
|
||||
this.prepareUpload = this.prepareUpload.bind(this)
|
||||
|
||||
if (typeof this.opts.limit === 'number' && this.opts.limit !== 0) {
|
||||
this.limitRequests = limitPromises(this.opts.limit)
|
||||
} else {
|
||||
this.limitRequests = (fn) => fn
|
||||
}
|
||||
}
|
||||
|
||||
getUploadParameters (file) {
|
||||
|
|
@ -58,11 +65,13 @@ module.exports = class AwsS3 extends Plugin {
|
|||
})
|
||||
})
|
||||
|
||||
const getUploadParameters = this.limitRequests(this.opts.getUploadParameters)
|
||||
|
||||
return Promise.all(
|
||||
fileIDs.map((id) => {
|
||||
const file = this.uppy.getFile(id)
|
||||
const paramsPromise = Promise.resolve()
|
||||
.then(() => this.opts.getUploadParameters(file))
|
||||
.then(() => getUploadParameters(file))
|
||||
return paramsPromise.then((params) => {
|
||||
this.uppy.emit('preprocess-progress', file.id, {
|
||||
mode: 'determinate',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue