1

I have a bucket already created but I want to create new folders inside this bucket, not upload data or anything else, just create new folders. How can I do this ?

Thanks

Laerte Junior
  • 244
  • 3
  • 16
  • Possible duplicate of [Amazon S3 boto - how to create a folder?](https://stackoverflow.com/questions/1939743/amazon-s3-boto-how-to-create-a-folder) – dmulter Sep 12 '18 at 20:35

3 Answers3

5

AWS S3 doesn't really have a first class concept of a "folder" or "directory". S3 objects have prefixes, which are segmented by slashes, so there is certainly the appearance of folders, but it is not possible to have a truly empty directory structure.

However, their AWS Console user experience does present content as such, and provides a button to "Create Folder". When using that button, the UI provides the below message:

When you create a folder, S3 console creates an object with the above name appended by suffix "/" and that object is displayed as a folder in the S3 console.

You could try using PowerShell's Put Object API/cmdlet to create empty objects named per that instruction. For example, you could create a folder named "my-new-folder" by creating an object named "my-new-folder/".

David Jetter
  • 131
  • 1
  • 4
2

S3 is object storage; it's not a regular file system. Generally speaking, there is no need to attempt to create folders. Simply upload objects, for example teams/east/falcons/logo.png.

If you really, really want to give the impression that there are folders then you can create zero-sized objects whose names ends in / (or whatever your preferred folder delimiter is). The simplest way to do this is with the AWS S3 console but any SDK will let you do it too (simply issue a PutObject with no body).

jarmod
  • 71,565
  • 16
  • 115
  • 122
0

I was seaching for this myself and found this.

use -content where content = key then -file or -folder are not needed

$s3Path = "/folder/" + 'subfolder/'
Write-S3Object -BucketName $s3Bucket -Key $s3Path -Content $s3Path 
tomerpacific
  • 4,704
  • 13
  • 34
  • 52
WouterAdam
  • 11
  • 1