From 203dc47b0f82befe2e931e23ff4b58b1573743cc Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 23 Jun 2023 17:15:25 +0200 Subject: [PATCH] @uppy/companion: fix part listing in s3 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. --- .../@uppy/companion/src/server/controllers/s3.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/@uppy/companion/src/server/controllers/s3.js b/packages/@uppy/companion/src/server/controllers/s3.js index 93b3f43626..283e56e958 100644 --- a/packages/@uppy/companion/src/server/controllers/s3.js +++ b/packages/@uppy/companion/src/server/controllers/s3.js @@ -159,7 +159,7 @@ module.exports = function s3 (config) { return } - let parts = [] + const parts = [] function listPartsPage (startAt) { client.send(new ListPartsCommand({ @@ -167,18 +167,18 @@ module.exports = function s3 (config) { Key: key, UploadId: uploadId, 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. - listPartsPage(data.NextPartNumberMarker) + listPartsPage(NextPartNumberMarker) } else { res.json(parts) } }, next) } - listPartsPage(0) + listPartsPage() } /**