From 81b0999e9fef39bd217932c4378fbba216e66f6c Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 14 Oct 2023 17:57:51 +0200 Subject: [PATCH] @uppy/aws-s3-multipart: fix `uploadURL` when using `PUT` (#4701) --- packages/@uppy/aws-s3-multipart/src/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/@uppy/aws-s3-multipart/src/index.js b/packages/@uppy/aws-s3-multipart/src/index.js index 6d26e17616..d594064f0e 100644 --- a/packages/@uppy/aws-s3-multipart/src/index.js +++ b/packages/@uppy/aws-s3-multipart/src/index.js @@ -18,6 +18,13 @@ function assertServerError (res) { return res } +function removeMetadataFromURL (urlString) { + const urlObject = new URL(urlString) + urlObject.search = '' + urlObject.hash = '' + return urlObject.href +} + /** * Computes the expiry time for a request signed with temporary credentials. If * no expiration was provided, or an invalid value (e.g. in the past) is @@ -260,7 +267,7 @@ class HTTPCommunicationQueue { const { onProgress, onComplete } = chunk - return this.#uploadPartBytes({ + const result = await this.#uploadPartBytes({ signature: { url, headers, method }, body, size: data.size, @@ -268,6 +275,11 @@ class HTTPCommunicationQueue { onComplete, signal, }).abortOn(signal) + + return 'location' in result ? result : { + location: removeMetadataFromURL(url), + ...result, + } } /**