Skip to content

Commit

Permalink
Merge pull request #42 from EventoryHost/feature/item61
Browse files Browse the repository at this point in the history
s3 file api modify
  • Loading branch information
Harshitazz authored Oct 26, 2024
2 parents 3cc4045 + e053ccb commit c785fd4
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 c785fd4

Please sign in to comment.