I am using AWS S3, Node.js 18x. I have csv files under my S3 subfolders and I want to get those files with a specific date range when it was created for example (jan. 1 - 7 2023). I need those files to create my weekly report so instead of manually downloading the file and use excel to consolidate those files an want to automate it. I have already created a pre-code for consolidating the files my issue right now is how to get those files on my S3 bucket.
// const csv = require("csvtojson");
import {S3Client ,ListObjectsV2Command } from "@aws-sdk/client-s3";
const s3Client = new S3Client({});
export const handler = async(event) => {
// TODO implement
const params = {
Bucket : 'bucketName',
Prefix : 'Reports/customerJourney',
Delimiter: '/',
}
try{
const data = await S3Client.send(new ListObjectsV2Command(params));
console.log("Success", data.CommonPrefixes);
return data.CommonPrefixes;
} catch (err) {
console.log("Error", err);
}
};
I am taking the code step by step a the moment as of now the code was to show the folders under my S3 bucket but I am receiving response of null. Reference I found . I am not quite sure what went wrong on this, also suggestion's that I can explore are also very much appriciated.