0

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.

Mina Chan
  • 41
  • 8
  • What does the code do? What do you expect it to do? – Anon Coward Jan 17 '23 at 16:05
  • @AnonCoward As of now my code is for listing the folders and files from S3 bucket, but as of now it is not showing my specific folder which is 'Reports/customerJourney/'. – Mina Chan Jan 18 '23 at 03:41

0 Answers0