upload file working, need to implement api call to backend service

This commit is contained in:
Khalim Conn-Kowlessar 2023-07-14 15:19:28 +01:00
parent c8e200eda7
commit 9be55a54bf

View file

@ -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 });
},