AWS S3 listing file without extension

31 Views Asked by At

My current file structure is

url/demo/file.txt
url/demo(file without extension)

Now when I try to list the file without extension it using prefix demo it also list the files in folder demo

Is there a way to just list a single object with demo without fetching files in folder demo

Also wanted to understand why and how does AWS allows same file / folder at same level with same name. Azure and other File system gives a conflict error

1

There are 1 best solutions below

5
John Rotenstein On

Amazon S3 does not use folders. Instead, the Key (filename) of objects includes the full path. So the first file is actually called url/demo/file.txt and the second one is called url/demo.

While the user interface presents the concept of folders, they do no actually exist. For example, you could upload a file to that demo folder without first creating the folder and the folder will magically appear. Then, if you delete the object, the folder will magically disappear (because it never actually existed).

If you create a folder in the S3 management console, it will actually create a zero-length object with the same name as the folder. This will 'force' the folder to appear in the UI even though there are no objects with that Prefix.

You can list objects in the specific 'folder' by specifying a delimiter and a prefix.