Added try block around s3 upload

This commit is contained in:
Khalim Conn-Kowlessar 2023-07-14 15:46:40 +01:00
parent e82e340325
commit 6d4988c46b

View file

@ -38,17 +38,18 @@ async function uploadCsvToS3({
presignedUrl: string;
file: File;
}) {
const upload = await fetch(presignedUrl, {
method: "PUT",
body: file,
headers: { "Content-Type": "text/csv" },
});
if (!upload.ok) {
try {
await fetch(presignedUrl, {
method: "PUT",
body: file,
headers: { "Content-Type": "text/csv" },
});
} catch (error) {
console.error(error);
throw new Error("Upload failed.");
}
return upload;
return { success: true };
}
export const SubmitPlan = ({