diff options
author | Chocobozzz <me@florianbigard.com> | 2021-09-08 16:45:02 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-09-08 16:45:02 +0200 |
commit | 1c93ad0778d9bde1ba4caf87f24ecef27a8346a9 (patch) | |
tree | a5d91cb9d90ac3486f339b8fb2b2652766bb1a77 /server/lib/object-storage/shared | |
parent | 8a7abfef88b5fc69f8809dcbb511e923597a0163 (diff) | |
download | PeerTube-1c93ad0778d9bde1ba4caf87f24ecef27a8346a9.tar.gz PeerTube-1c93ad0778d9bde1ba4caf87f24ecef27a8346a9.tar.zst PeerTube-1c93ad0778d9bde1ba4caf87f24ecef27a8346a9.zip |
Fix object storage multipart upload
Diffstat (limited to 'server/lib/object-storage/shared')
-rw-r--r-- | server/lib/object-storage/shared/client.ts | 14 | ||||
-rw-r--r-- | server/lib/object-storage/shared/object-storage-helpers.ts | 2 |
2 files changed, 15 insertions, 1 deletions
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 () { | |||
29 | : undefined | 29 | : undefined |
30 | }) | 30 | }) |
31 | 31 | ||
32 | // FIXME: https://github.com/aws/aws-sdk-js-v3/issues/2445 workaround | ||
33 | s3Client.middlewareStack.add( | ||
34 | (next, _context) => (args: any) => { | ||
35 | if (typeof args.request?.body === 'string' && args.request.body.includes('CompletedMultipartUpload')) { | ||
36 | args.request.body = args.request.body.replace(/CompletedMultipartUpload/g, 'CompleteMultipartUpload') | ||
37 | } | ||
38 | return next(args) | ||
39 | }, | ||
40 | { | ||
41 | step: 'build', | ||
42 | priority: 'high' | ||
43 | } | ||
44 | ) | ||
45 | |||
32 | logger.info('Initialized S3 client %s with region %s.', getEndpoint(), OBJECT_STORAGE.REGION, lTags()) | 46 | logger.info('Initialized S3 client %s with region %s.', getEndpoint(), OBJECT_STORAGE.REGION, lTags()) |
33 | 47 | ||
34 | return s3Client | 48 | 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: { | |||
216 | 216 | ||
217 | const completeUploadCommand = new CompleteMultipartUploadCommand({ | 217 | const completeUploadCommand = new CompleteMultipartUploadCommand({ |
218 | Bucket: bucketInfo.BUCKET_NAME, | 218 | Bucket: bucketInfo.BUCKET_NAME, |
219 | Key: objectStorageKey, | 219 | Key: key, |
220 | UploadId: createResponse.UploadId, | 220 | UploadId: createResponse.UploadId, |
221 | MultipartUpload: { Parts: parts } | 221 | MultipartUpload: { Parts: parts } |
222 | }) | 222 | }) |