Explorar el Código

Upload protocol "s3-multipart" does not use the chunkSize option (#3511)

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
Gabi Ganam hace 3 años
padre
commit
db634c12a7
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      packages/@uppy/companion/src/server/Uploader.js

+ 10 - 0
packages/@uppy/companion/src/server/Uploader.js

@@ -600,6 +600,14 @@ class Uploader {
     const filename = this.uploadFileName
     const { client, options } = this.options.s3
 
+    function getPartSize (chunkSize) {
+      // backwards compatibility https://github.com/transloadit/uppy/pull/3511#issuecomment-1050797935
+      // requires min 5MiB and max 5GiB partSize
+      // todo remove this logic in the next major semver
+      if (chunkSize == null || chunkSize >= 5368709120 || chunkSize <= 5242880) return undefined
+      return chunkSize
+    }
+
     const upload = client.upload({
       Bucket: options.bucket,
       Key: options.getKey(null, filename, this.options.metadata),
@@ -607,6 +615,8 @@ class Uploader {
       ContentType: this.options.metadata.type,
       Metadata: this.options.metadata,
       Body: stream,
+    }, {
+      partSize: getPartSize(this.options.chunkSize),
     })
 
     upload.on('httpUploadProgress', ({ loaded, total }) => {