From 9be55a54bf71be9f56ed15f2ddbb3897d16f46c4 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 14 Jul 2023 15:19:28 +0100 Subject: [PATCH] upload file working, need to implement api call to backend service --- src/app/components/portfolio/UploadCsvModal.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/components/portfolio/UploadCsvModal.tsx b/src/app/components/portfolio/UploadCsvModal.tsx index 2a619e4..cb41cf2 100644 --- a/src/app/components/portfolio/UploadCsvModal.tsx +++ b/src/app/components/portfolio/UploadCsvModal.tsx @@ -39,10 +39,10 @@ async function uploadCsvToS3({ presignedUrl: string; file: File; }) { - console.log("Uploading file to s3"); const upload = await fetch(presignedUrl, { method: "PUT", body: file, + headers: { "Content-Type": "text/csv" }, }); if (!upload.ok) { @@ -64,7 +64,7 @@ export const SubmitPlan = ({ goal: string; housingType: string; goalValue: string; - file: File | null; + file: File; portfolioId: number; }) => { const router = useRouter(); @@ -87,6 +87,7 @@ export const SubmitPlan = ({ const { mutate, isLoading } = useMutation(generatePresignedUrl, { onSuccess: (data) => { + console.log("Got url: ", data.url); // After the presigned URL has been generated, we can upload the file to S3 mutateUploadCsv({ presignedUrl: data.url, file: file }); },