Skip to content

Commit

Permalink
fix: s3 upload
Browse files Browse the repository at this point in the history
  • Loading branch information
KishenKumarrrrr committed Feb 8, 2024
1 parent a42f401 commit 8fcc521
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions frontend/src/services/upload.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function getMd5(blob: Blob): Promise<string> {
export async function uploadFileWithPresignedUrl(
uploadedFile: File,
_presignedUrl: string // Making this unused because the endpoint below generates its own presignedUrl and uploads the file
): Promise<string> {
) {
try {
const formData = new FormData()
formData.append('file', uploadedFile)
Expand All @@ -73,7 +73,10 @@ export async function uploadFileWithPresignedUrl(
'Content-Type': 'multipart/form-data',
},
})
return response.data.etag
return {
etag: response.data.etag,
transactionId: response.data.transactionId,
}
} catch (e) {
errorHandler(
e,
Expand Down Expand Up @@ -210,15 +213,15 @@ export async function uploadFileToS3(
uploadedFile: file,
})
// Upload to presigned url
const etag = await uploadFileWithPresignedUrl(
const result = await uploadFileWithPresignedUrl(
file,
startUploadResponse.presignedUrl
)
await completeFileUpload({
campaignId: +campaignId,
transactionId: startUploadResponse.transactionId,
transactionId: result.transactionId,
filename: file.name,
etag,
etag: result.etag,
})
return file.name
}
Expand Down

0 comments on commit 8fcc521

Please sign in to comment.