@uppy/aws-s3-multipart: fix support for non-multipart PUT upload (#4568)

This commit is contained in:
Antoine du Hamel 2023-07-11 16:16:10 +02:00 committed by GitHub
parent 7dcf8c2f36
commit 6ae15f441e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -223,16 +223,22 @@ class HTTPCommunicationQueue {
headers,
} = await this.#getUploadParameters(file, { signal }).abortOn(signal)
const formData = new FormData()
Object.entries(fields).forEach(([key, value]) => formData.set(key, value))
let body
const data = chunk.getData()
formData.set('file', data)
if (method === 'post') {
const formData = new FormData()
Object.entries(fields).forEach(([key, value]) => formData.set(key, value))
formData.set('file', data)
body = formData
} else {
body = data
}
const { onProgress, onComplete } = chunk
return this.#uploadPartBytes({
signature: { url, headers, method },
body: formData,
body,
size: data.size,
onProgress,
onComplete,