0

I'm working on a program which backs up some directory and all of it's files into S3. Everything works great, except if I want to create an empty "folder" in S3.

When I'm working in the S3 console, it is possible to accomplish this by pressing the "Create Folder" button, but my problem is when I try to do this using AWSSDK, my folder does not show up because it does not have any contents.

My current approach to this problem is uploading a randomly generated file (0 Bytes) into this empty folder, but this file is not part of the user's files, and doesn't help retain the file after being deleted.

Is there a better approach to creating an EMPTY folder that I am missing?

  • read accepted answer on this question: https://stackoverflow.com/questions/9944671/amazon-s3-creating-folder-through-net-sdk-vs-through-management-console in short: `Amazon S3 data model does not have the concept of folders. ` – Leo Oct 29 '19 at 20:40
  • @LeonardoSeccia Thank you for linking me that. I understand that there are no folders in S3 (hence the "folder"). From what I understood - it is impossible to create an empty directory and have it be visible in the console unless you do it from the console itself. Is my takeaway correct? – Andrew the Programmer Oct 29 '19 at 20:57
  • 1
    Essentially yes... There is no standard way of emulating empty folders so it is up to you how you do it within your application. So unless it is the same as the way the console or other apps do it then your solution will not be compatible with theirs. – Leo Oct 29 '19 at 20:59
  • @LeonardoSeccia That's unfortunate to know. I'll clarify the specs and see what the best workaround would be to this. Thanks for you input, friend – Andrew the Programmer Oct 29 '19 at 21:01
  • No worries, good luck! – Leo Oct 29 '19 at 21:02
  • 1
    When an empty folder is created in the Amazon S3 console, it actually creates a zero-length object with the name of the 'folder'. This causes the 'folder' to become a "common prefix", which is similar in concept to a folder. You can do the same thing in code by creating a zero-length object with the desired name of the folder. However, there is rarely a need to do such a thing, because folders magically appear whenever they are referenced in the Key of an object. – John Rotenstein Oct 30 '19 at 02:42

0 Answers0