Fix for upload parameters and api client handling of empty responses. AWS put returns no body on a 200 so response.json would mistakenly throw an error
This commit is contained in:
parent
2ff1c7ad28
commit
a7be765bf1
|
@ -88,12 +88,12 @@
|
||||||
})
|
})
|
||||||
loading = true
|
loading = true
|
||||||
try {
|
try {
|
||||||
const res = await API.externalUpload({
|
const res = await API.externalUpload(
|
||||||
datasourceId,
|
datasourceId,
|
||||||
bucket,
|
bucket,
|
||||||
key: processedFileKey,
|
processedFileKey,
|
||||||
data,
|
data
|
||||||
})
|
)
|
||||||
notificationStore.actions.success("File uploaded successfully")
|
notificationStore.actions.success("File uploaded successfully")
|
||||||
loading = false
|
loading = false
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -163,7 +163,13 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
|
||||||
} else if (parseResponse) {
|
} else if (parseResponse) {
|
||||||
return await parseResponse(response)
|
return await parseResponse(response)
|
||||||
} else {
|
} else {
|
||||||
return (await response.json()) as ResponseT
|
const text = await response.text()
|
||||||
|
// If the response has no body at all e.g s3.put
|
||||||
|
if (!text) {
|
||||||
|
// Empty response
|
||||||
|
return {} as ResponseT
|
||||||
|
}
|
||||||
|
return JSON.parse(text) as ResponseT
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
delete cache[url]
|
delete cache[url]
|
||||||
|
|
Loading…
Reference in New Issue