A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: handle errors when resolving upload urls
Abdullah Attaa6af92c33040
diff --git a/apps/web/src/interfaces/fs.ts b/apps/web/src/interfaces/fs.tsindex def02295e..5e8c2cc0a 100644--- a/apps/web/src/interfaces/fs.ts+++ b/apps/web/src/interfaces/fs.ts@@ -296,12 +296,15 @@ async function singlePartUploadFile(console.log("Streaming file upload!");const { url, headers, signal } = requestOptions;- const uploadUrl = await fetch(url, {+ const uploadUrl: string | { error?: string } = await fetch(url, {method: "PUT",headers,signal- }).then((res) => (res.ok ? res.text() : null));- if (!uploadUrl) throw new Error("Unable to resolve attachment upload url.");+ }).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({url: uploadUrl,@@ -354,6 +357,9 @@ async function multiPartUploadFile(throw new WrappedError("Could not initiate multi-part upload.", e);});+ if (initiateMultiPartUpload.data.error)+ throw new Error(initiateMultiPartUpload.data.error);+uploadId = initiateMultiPartUpload.data.uploadId;const { parts } = initiateMultiPartUpload.data;