mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
web: upload direct to s3 via proxy
This commit is contained in:
@@ -300,20 +300,11 @@ async function singlePartUploadFile(
|
|||||||
console.log("Streaming file upload!");
|
console.log("Streaming file upload!");
|
||||||
const { url, headers, signal } = requestOptions;
|
const { url, headers, signal } = requestOptions;
|
||||||
|
|
||||||
const uploadUrl: string | { error?: string } = await fetch(url, {
|
|
||||||
method: "PUT",
|
|
||||||
headers,
|
|
||||||
signal
|
|
||||||
}).then((res) => (res.ok ? res.text() : res.json()));
|
|
||||||
if (typeof uploadUrl !== "string")
|
|
||||||
throw new Error(
|
|
||||||
uploadUrl.error || "Unable to resolve attachment upload url."
|
|
||||||
);
|
|
||||||
|
|
||||||
const response = await axios.request({
|
const response = await axios.request({
|
||||||
url: uploadUrl,
|
url,
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: {
|
||||||
|
...headers,
|
||||||
"Content-Type": ""
|
"Content-Type": ""
|
||||||
},
|
},
|
||||||
data: await fileHandle.toBlob(),
|
data: await fileHandle.toBlob(),
|
||||||
|
|||||||
Reference in New Issue
Block a user