Skip to content

Commit

Permalink
Add required variabled in env example
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-dharti-r committed Jul 8, 2024
1 parent fd64123 commit c10b3fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 3 additions & 0 deletions admin/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 4 additions & 7 deletions admin/utils/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
});

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

Expand Down

0 comments on commit c10b3fb

Please sign in to comment.