Skip to content

Commit

Permalink
s3 file api modify
Browse files Browse the repository at this point in the history
  • Loading branch information
harshita committed Oct 26, 2024
1 parent 3243f70 commit e053ccb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions routes/fileRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ const s3Client = new S3Client({
});

function getFileNameFromUrl(url) {
const comIndex = url.indexOf(".com");
const decodedUrl = decodeURIComponent(url);
const comIndex = decodedUrl.indexOf(".com");

if (comIndex === -1) {
return null;
}

const substringAfterCom = url.substring(comIndex + 4);
const substringAfterCom = decodedUrl.substring(comIndex + 4);

const dashIndex = substringAfterCom.indexOf("-");

Expand All @@ -33,8 +34,10 @@ function getFileNameFromUrl(url) {

// Function to get the file size from S3 using AWS SDK v3
async function getFileSizeFromS3(url) {
const decodedUrl = decodeURIComponent(url);

const bucketName = "eventory-bucket"; // replace with your S3 bucket name
const key = url.split(".com/")[1]; // Extract the key from the URL
const key = decodedUrl.split(".com/")[1]; // Extract the key from the URL

const params = {
Bucket: bucketName,
Expand Down

0 comments on commit e053ccb

Please sign in to comment.