S3 Digital Ocean file listing v folder listing

Hi Wapplers,

I have setup S3 space storage on Digital Ocean.

I am successfully retrieving all files in a folder, but its showing me the folder name as well. Please see image below.

What I want it to show is only the folder name ID, not the contents inside. I am using below config:

Any idea what is going on?

bump

Maybe you should post the output of the List files action, as well as the code for the display from your first screenshot.

deleted

deleted

It’s strange that it lists all files and folders rather than just the folder… maybe this is a limitation of S3 on Wappler?

You are using a List Files action…why do you find it strange that it is returning a list of files?

I guess… so does this come down to a limitation of S3 that there is no “Listfolder” action?

I think you might be confused on folders within S3; In fact, there is no such thing. S3 stores objects in a bucket, and those objects have a key. The key is there to help you group files, which gives the appearance of folders, but there really are no folders.

Here is what Amazon says regarding this:

In Amazon S3, buckets and objects are the primary resources, and objects are stored in buckets. Amazon S3 has a flat structure instead of a hierarchy like you would see in a file system. However, for the sake of organizational simplicity, the Amazon S3 console supports the folder concept as a means of grouping objects. The console does this by using a shared name prefix for the grouped objects. In other words, the grouped objects have names that begin with a common string. This common string, or shared prefix, is the folder name. Object names are also referred to as key names .

Some more:

Important

When you create a folder in Amazon S3, S3 creates a 0-byte object with a key that’s set to the folder name that you provided. For example, if you create a folder named photos in your bucket, the Amazon S3 console creates a 0-byte object with the key photos/ . The console creates this object to support the idea of folders.

The Amazon S3 console treats all objects that have a forward slash ( / ) character as the last (trailing) character in the key name as a folder (for example, examplekeyname/ ). You can’t upload an object that has a key name with a trailing / character by using the Amazon S3 console. However, you can upload objects that are named with a trailing / with the Amazon S3 API by using the AWS Command Line Interface (AWS CLI), AWS SDKs, or REST API.

An object that is named with a trailing / appears as a folder in the Amazon S3 console. The Amazon S3 console does not display the content and metadata for such an object. When you use the console to copy an object named with a trailing / , a new folder is created in the destination location, but the object’s data and metadata are not copied.

Ah ok. So I can’t really list a folder (or key) without it’s contents? If I try list an object on the client side instead of “Key” in my table, it comes out as Object Object

If your example list of contents is consistent, then you could filter out anything that doesn’t end with a trailing slash to get your folders.

Or perhaps filter on Size == 0

Thank you… where do I apply the filter? on the sever action or client side?

It depends on the use case, but generally speaking I would start with server side.

If I do it on the server side, there is no filter option in the listfiles action… where would I apply the filter?

Just use a set value action

listFiles.Contents.where('Size', '==', 0)
1 Like

You sir are a legend. That worked perfectly.

Thank you for your patience!

1 Like