瀏覽代碼

@uppy/companion: fix part listing in s3 (#4524)

Attempting to list a multipart upload with 0 uploaded parts would return
an empty array with AWS SDK v2, and returns `undefined` with AWS SDK v3.
Antoine du Hamel 1 年之前
父節點
當前提交
e289c8404c
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6 6
      packages/@uppy/companion/src/server/controllers/s3.js

+ 6 - 6
packages/@uppy/companion/src/server/controllers/s3.js

@@ -159,7 +159,7 @@ module.exports = function s3 (config) {
       return
       return
     }
     }
 
 
-    let parts = []
+    const parts = []
 
 
     function listPartsPage (startAt) {
     function listPartsPage (startAt) {
       client.send(new ListPartsCommand({
       client.send(new ListPartsCommand({
@@ -167,18 +167,18 @@ module.exports = function s3 (config) {
         Key: key,
         Key: key,
         UploadId: uploadId,
         UploadId: uploadId,
         PartNumberMarker: startAt,
         PartNumberMarker: startAt,
-      })).then(data => {
-        parts = parts.concat(data.Parts)
+      })).then(({ Parts, IsTruncated, NextPartNumberMarker }) => {
+        if (Parts) parts.push(...Parts)
 
 
-        if (data.IsTruncated) {
+        if (IsTruncated) {
           // Get the next page.
           // Get the next page.
-          listPartsPage(data.NextPartNumberMarker)
+          listPartsPage(NextPartNumberMarker)
         } else {
         } else {
           res.json(parts)
           res.json(parts)
         }
         }
       }, next)
       }, next)
     }
     }
-    listPartsPage(0)
+    listPartsPage()
   }
   }
 
 
   /**
   /**