C List all files with filename under a amazon S3 folder

0 votes

Using C# and amazon .Net SDK,able to list all the files with in a amazon S3 folder as below:

ListObjectsRequest request = new ListObjectsRequest();           
            request.BucketName = _bucketName; //Amazon Bucket Name
            request.Prefix = _sourceKey; //Amazon S3 Folder path           
            do
            {
                ListObjectsResponse response = _client.ListObjects(request);//_client - AmazonS3Client

Out put:

    Folder
    Folder/file1.pdf
    Folder/file2.pdf
    Folder/file3.pdf

But i wanted to achieve something like this: Desired Output:

file1.pdf
file2.pdf
file3.pdf

Thanks in advance

Oct 5, 2018 in AWS by eatcodesleeprepeat
• 4,710 points
17,284 views

1 answer to this question.

0 votes

Also you can use the following c# code to retrieve the files information.

    string bucketName = "your bucket";
    AmazonS3Client s3Client = new AmazonS3Client("your access key", "your secret key", cfg);
    S3DirectoryInfo dir = new S3DirectoryInfo(s3Client, bucketName, "your AmazonS3 folder name");
    foreach (IS3FileSystemInfo file in dir.GetFileSystemInfos())
    {
        Console.WriteLine(file.Name);
        Console.WriteLine(file.Extension);
        Console.WriteLine(file.LastWriteTime);
    }

I am using amazon AWSSDK.Core and AWSSDK.S3 version 3.1.0.0 for .net 3.5. I hope it can help you

answered Oct 5, 2018 by Priyaj
• 58,020 points
but this does not give filesize, i have tried through Amazon.S3.IO.S3FileInfo, but here i have to created object

in the loop
Hi,

Can you share your error while trying the above solution?

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
11,443 views
0 votes
1 answer

How to list all the objects in Amazon S3?

As stated already, Amazon S3 indeed requires ...READ MORE

answered Oct 5, 2018 in AWS by Archana
• 4,170 points
7,517 views
0 votes
1 answer

AWS S3 uploading hidden files by default

versioning is enabled in your bucket. docs.aws.amazon.com/AmazonS3/latest/user-guide/….... the ...READ MORE

answered Oct 4, 2018 in AWS by Priyaj
• 58,020 points
6,004 views
–1 vote
1 answer

How to decrypt the encrypted S3 file using aws-encryption-cli --decrypt

Use command : aws s3 presign s3://mybucket/abc_count.png you get ...READ MORE

answered Oct 22, 2018 in AWS by Priyaj
• 58,020 points
5,231 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,820 points
2,883 views
0 votes
2 answers
+2 votes
3 answers

AWS S3 - Listing all objects inside a folder without the prefix

For Scala developers, here it is recursive ...READ MORE

answered Sep 20, 2018 in AWS by Priyaj
• 58,020 points
48,920 views
+3 votes
6 answers

How to move files from amazon ec2 to s3 bucket using command line

Hey, 3 ways you can do this: To ...READ MORE

answered Oct 9, 2018 in AWS by Omkar
• 69,220 points
20,068 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP