Folder Management Overview
OBS uses a flat storage architecture that scales well for massive datasets. However, when a bucket contains a large number of objects, all items appear in a single flat list. This flat layout makes it difficult to search, organize, or perform batch operations and also provides no clear logical grouping for service data. To address these issues, OBS offers a folder view in tools such as OBS Console and OBS Browser+.
How It Works
OBS stores data in buckets as objects. All objects in a bucket exist at the same logical level and have no hierarchical relationships. There are no real folders in OBS. The folders you see on OBS Console and OBS Browser+ are virtual folders. OBS automatically generates them based on the slashes (/) in object names.
As shown in Figure 1, OBS Console and OBS Browser+ handle folders using the following logic:
- Slash-based hierarchy: If an object is named Dir1/Dir2/test1.txt, the console displays a folder named Dir1, which contains a subfolder named Dir2. The Dir2 subfolder contains the object test1.txt. In addition, any object whose name ends with a slash (/) is displayed as a folder on the console. For example, Dir1/Dir2/ is shown as a folder on the console.
- Empty folder creation: Creating a folder that contains no objects on OBS Console results in a 0-byte object. The object name is the folder name you provide plus a slash (/). For example, creating a folder named Dir generates a 0-byte object named Dir/.
- Prefix-based grouping: Objects with the same prefix (in the format of xxx/) are automatically grouped into the same folder. For example, log/log1.txt and log/log2.txt are grouped into the log folder. Similarly, Dir1/Dir2/test1.txt and Dir1/Dir2/test2.txt are grouped into the Dir2 subfolder under Dir1.
Folder Operations
| Operation | Description |
|---|---|
| Create a folder in a bucket to help organize data stored in OBS. | |
| Share an entire folder in OBS with anonymous users. | |
| Collect statistics on the total size and number of objects in a folder. |
Best Practices for Using Folders
- Configure folder permissions based on prefix matching. To configure access permissions for the Dir folder in the exampleBucket bucket, specify the Resource field in the IAM policy or bucket policy as shown in the following example. Note that you must use the wildcard (*) to apply permissions to all objects in the folder. Do not mistakenly grant permissions only to the 0-byte object Dir/.
- Bucket policy: The following example grants permission to download all objects in the Dir folder in the exampleBucket bucket.
{ "Statement": [ { "Sid": "DirTest", "Effect": "Allow", "Principal": { "ID": [ "domain/exampleDomainID:user/exampleUserID" ] }, "Action": [ "GetObject" ], "Resource": [ "exampleBucket/Dir/*" ] } ] } - IAM policy: The following example grants permission to download all objects in the Dir folder in the exampleBucket bucket.
{ "Version": "1.1", "Statement": [ { "Effect": "Allow", "Action": [ "obs:object:GetObject" ], "Resource": [ "OBS:*:*:object:exampleBucket/Dir/*" ] } ] }
- Bucket policy: The following example grants permission to download all objects in the Dir folder in the exampleBucket bucket.
- Avoid deep folder nesting (for example, Dir1/Dir2/Dir3/Dir4/.../test.txt). Long prefix paths increase the cost of prefix filtering and can slow down object listing.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
