Przeglądaj źródła

@uppy/aws-s3-multipart: fix `uploadURL` when using `PUT` (#4701)

Antoine du Hamel 1 rok temu
rodzic
commit
81b0999e9f
1 zmienionych plików z 13 dodań i 1 usunięć
  1. 13 1
      packages/@uppy/aws-s3-multipart/src/index.js

+ 13 - 1
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,
+    }
   }
 
   /**