From cb7f104b1d78ef0277f0d10c6e72cc3f822d513b Mon Sep 17 00:00:00 2001 From: shb Date: Wed, 18 Jun 2025 12:13:06 +0800 Subject: [PATCH] Removed sending file to the backend Direct-to-storage upload instead of sending to the backend since sending files to the backend from the frontend is forbidden for some reason. --- components/dms/dialogs/UploadWithMetadataModal.vue | 3 +-- server/api/dms/upload-file.post.js | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/components/dms/dialogs/UploadWithMetadataModal.vue b/components/dms/dialogs/UploadWithMetadataModal.vue index 892781c..2844d4b 100644 --- a/components/dms/dialogs/UploadWithMetadataModal.vue +++ b/components/dms/dialogs/UploadWithMetadataModal.vue @@ -334,13 +334,12 @@ const performUpload = async () => { const formData = new FormData(); formData.append('fileName', metadata.name); - formData.append('file', file); + // formData.append('file', file); console.log(formData); const response = await fetch('/api/dms/upload-file', { method: "POST", - // Let browser automatically set headers for multipart/form-data body: formData, }); console.log(response); diff --git a/server/api/dms/upload-file.post.js b/server/api/dms/upload-file.post.js index 6b16607..d32c2f1 100644 --- a/server/api/dms/upload-file.post.js +++ b/server/api/dms/upload-file.post.js @@ -42,7 +42,7 @@ export default defineEventHandler(async (event) => { } // Create S3 client with config - const client = new S3Client(S3_Config); + const s3Client = new S3Client(S3_Config); // const { fileName, file } = await readMultipartFormData(event); @@ -69,7 +69,7 @@ export default defineEventHandler(async (event) => { const command = new PutObjectCommand(input); try { - const response = await client.send(command); + const response = await s3Client.send(command); console.log(response); return response; } catch (error) {