From 1c93ad0778d9bde1ba4caf87f24ecef27a8346a9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Sep 2021 16:45:02 +0200 Subject: [PATCH] Fix object storage multipart upload --- server/lib/object-storage/shared/client.ts | 14 ++++++++++++++ .../shared/object-storage-helpers.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/server/lib/object-storage/shared/client.ts b/server/lib/object-storage/shared/client.ts index c9a614593..85682c492 100644 --- a/server/lib/object-storage/shared/client.ts +++ b/server/lib/object-storage/shared/client.ts @@ -29,6 +29,20 @@ function getClient () { : undefined }) + // FIXME: https://github.com/aws/aws-sdk-js-v3/issues/2445 workaround + s3Client.middlewareStack.add( + (next, _context) => (args: any) => { + if (typeof args.request?.body === 'string' && args.request.body.includes('CompletedMultipartUpload')) { + args.request.body = args.request.body.replace(/CompletedMultipartUpload/g, 'CompleteMultipartUpload') + } + return next(args) + }, + { + step: 'build', + priority: 'high' + } + ) + logger.info('Initialized S3 client %s with region %s.', getEndpoint(), OBJECT_STORAGE.REGION, lTags()) return s3Client diff --git a/server/lib/object-storage/shared/object-storage-helpers.ts b/server/lib/object-storage/shared/object-storage-helpers.ts index b53b94b96..47c37ffda 100644 --- a/server/lib/object-storage/shared/object-storage-helpers.ts +++ b/server/lib/object-storage/shared/object-storage-helpers.ts @@ -216,7 +216,7 @@ async function multiPartUpload (options: { const completeUploadCommand = new CompleteMultipartUploadCommand({ Bucket: bucketInfo.BUCKET_NAME, - Key: objectStorageKey, + Key: key, UploadId: createResponse.UploadId, MultipartUpload: { Parts: parts } })