Fix object storage multipart upload

This commit is contained in:
Chocobozzz 2021-09-08 16:45:02 +02:00
parent 8a7abfef88
commit 1c93ad0778
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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 }
})