As per my understanding, object storage has a 'flat' structure so you cannot create folders within buckets. However, in both GCP & AWS, I am able to upload regular folders to the buckets, which also look like regular folders on their web UI console. What is the difference between the folders I am seeing on these buckets, and the folders which are there in a file-storage system (like my personal laptop)?
CodePudding user response:
As far as I know Object Storage has a 'flat' structure so you cannot create folders within buckets, nor can you nest buckets in buckets.
If you need to have some form of 'folder'-like structure, then using prefixes is the way to go. You'll then end up with this structure: {endpoint}/{bucket-name}/{object-prefix}/{object-name}.
thats what you are seeing according to me
CodePudding user response:
Amazon S3 has a flat structure instead of a hierarchy as 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. It does this by using a shared name prefix for objects (that is, objects have names that begin with a common string). Object names are also referred to as key names.
For example, you can create a folder on the console named photos and store an object named myphoto.jpg
in it. The object is then stored with the key name photos/myphoto.jpg
, where photos/
is the prefix.
Here are two more examples:
- If you have three objects in your bucket—
logs/date1.txt
,logs/date2.txt
, andlogs/date3.txt
—the console will show a folder namedlogs
. If you open the folder in the console, you will see three objects:date1.txt
,date2.txt
, anddate3.txt
. - If you have an object named
photos/2017/example.jpg
, the console will show you a folder named photos containing the folder2017
. The folder2017
will contain the objectexample.jpg
.
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.
You can read more in the Amazon S3 user guide.