diff --git a/admin/.env.example b/admin/.env.example index bac4133..92a7539 100644 --- a/admin/.env.example +++ b/admin/.env.example @@ -6,6 +6,9 @@ NEXT_PUBLIC_CRYPTO_SECRET="A Random Key to Encrypt/Decrypt Password" NEXT_PUBLIC_AWS_REGION="Your AWS Account Region" NEXT_PUBLIC_AWS_ACCESS_KEY_ID="Your AWS Account Access Key" NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY="Your AWS Account Secret Access Key" +NEXT_PUBLIC_AWS_BUCKET_NAME="Your s3 Bucket Name" +NEXT_PUBLIC_ACCESS_KEY_ID="Your s3 Bucket User Access Key" +NEXT_PUBLIC_SECRET_ACCESS_KEY="Your s3 Bucket User Secret Key" NEXT_PUBLIC_MAIL_SENDER="Your Mail Sender Email Id" NEXT_PUBLIC_SUPABASE_STORAGE_URL="Your Supabase Storage URL" NEXT_PUBLIC_SUPABASE_USER="Your Supabase User Email for Auth" diff --git a/admin/utils/image.ts b/admin/utils/image.ts index 545cd86..a33f54d 100644 --- a/admin/utils/image.ts +++ b/admin/utils/image.ts @@ -15,10 +15,7 @@ const s3 = new S3Client({ }, }); -const bucketUrl = - "https://bitespace.s3." + - process.env.NEXT_PUBLIC_AWS_REGION + - ".amazonaws.com/"; +const bucketUrl = `https://${process.env.NEXT_PUBLIC_AWS_BUCKET_NAME}.s3.${process.env.NEXT_PUBLIC_AWS_REGION}.amazonaws.com/`; const getFilenameFromURL = (url: string) => { const path = new URL(url).pathname; @@ -59,7 +56,7 @@ const changeFileExtensionToWebpExtension = (name: string) => { const uploadFileTos3 = async (bucket: string, file: any, fileName: string) => { let uploadParams = { - Bucket: "bitespace", + Bucket: process.env.NEXT_PUBLIC_AWS_BUCKET_NAME, Body: file, ContentType: file.type, Key: bucket + "/" + fileName, @@ -71,7 +68,7 @@ const uploadFileTos3 = async (bucket: string, file: any, fileName: string) => { await s3.send(command); const getObj = new GetObjectCommand({ - Bucket: "bitespace", + Bucket: process.env.NEXT_PUBLIC_AWS_BUCKET_NAME, Key: bucket + "/" + fileName, }); @@ -90,7 +87,7 @@ const uploadFileTos3 = async (bucket: string, file: any, fileName: string) => { const deleteFileFroms3 = async (fileUrl: string) => { try { const deleteObj = new DeleteObjectCommand({ - Bucket: "bitespace", + Bucket: process.env.NEXT_PUBLIC_AWS_BUCKET_NAME, Key: fileUrl.replace(bucketUrl, ""), });