Scenarios
You can create folders in a bucket to help organize and manage your data in OBS.
Unlike traditional file systems, OBS does not use the concepts of files and folders. Instead, it provides a way to simulate folders for easier data management. On OBS Console or OBS Browser+, an object is simulated as a folder by adding a slash (/) to the end of the object name. When objects are listed via the API, the returned object name is the path, and the content after the last slash (/) is considered the actual object name. If the path ends with a slash (/), it indicates a folder. The hierarchical depth of a folder has no impact on object access performance.
Ways to Create a Folder
You can use OBS Console, APIs, SDKs, OBS Browser+, or obsutil to create a folder.
Using OBS Console
- In the navigation pane of OBS Console, choose Object Storage.
- In the bucket list, click the bucket you want to operate. The Objects page is displayed.
- Click Create Folder, or click a folder in the object list to open it and click Create Folder.
- In the Folder Name text box, enter a name for the folder.
- You can create single-level or multi-level folders.
- The name cannot contain the following special characters: \:*?"<>|
- The name cannot start or end with a period (.) or slash (/).
- The folder's absolute path cannot exceed 1,023 characters.
- Any single slash (/) separates and creates multiple levels of folders at once.
- The name cannot contain two or more consecutive slashes (/).
- Click OK.
Using APIs
To create a folder in OBS is to create an object whose size is 0 and whose name ends with a slash (/), in essential. For details, see Using APIs.
Using SDKs
To create a folder in OBS is to create an object whose size is 0 and whose name ends with a slash (/), in essential. For details, see Using SDKs.
Using the GUI Tool - OBS Browser+
- Log in to OBS Browser+.
- Click the bucket where you want to create a folder and click Create Folder.
- In the displayed dialog box, enter a folder name and click OK, as shown in Figure 1.
Figure 1 Creating a folder
- A folder name cannot contain the following special characters: \ : * ? ' < > |
- A folder name cannot start or end with a period (.) or slash (/).
- A folder name cannot exceed 1,023 bytes. The length of a folder name is the sum of the length of its own name and the length of its upper-level directory names. The total length cannot exceed 1,023 bytes. Directories of different levels are automatically separated by slashes (/). For example, if the upper-level directory of folder01 is folder02, the name length of folder folder01 is the length of folder02/folder01/.
- A single slash (/) separates and creates multiple levels of folders.
If an access deny message is displayed when you are creating a folder, possible causes are as follows:
- Access to the bucket is restricted by an ACL. For example, you do not have the write permission for the bucket.
- Access to the bucket is restricted by a bucket policy. For example, you do not have the write permission for the bucket, or write operations cannot be performed on the bucket during the current period.
If such message is displayed, check ACL and policy settings of the bucket and resolve the problem accordingly.
- Click OK.
Using the CLI Tool - obsutil
Command Line Structure
- In Windows
- In Linux or macOS
Examples
- Take the Windows OS as an example. Run the obsutil mkdir obs://bucket-test/folder1/folder2 command to create a folder in a bucket.
obsutil mkdir obs://bucket-test/folder1/folder2
The bucket [bucket-test] does not support POSIX, create folder(s) step by step
Create folder [obs://bucket-test/folder1/] successfully, request id [0000016979E1D23C860BB3D8E4577C5E]
Create folder [obs://bucket-test/folder1/folder2] successfully, request id [0000016979E1D2B2860BB5181229C72C]
Parameter Description
Parameter |
Optional or Mandatory |
Description |
bucket |
Mandatory when creating a folder in a specified bucket |
The bucket name |
folder |
Mandatory when creating a folder in a specified bucket |
The folder path in the bucket. This value can contain multi-level folders. Separate each level with a slash (/). |
folder_url |
Mandatory when creating a folder in the local file system |
The folder path in the local file system. The value can be an absolute path or a relative path. |
config |
Optional (additional parameter) |
The user-defined configuration file for executing the current command. To learn the parameters that can be configured in this file, see Configuration Parameters. |
e |
Optional (additional parameter) |
The endpoint |
i |
Optional (additional parameter) |
The user's AK |
k |
Optional (additional parameter) |
The user's SK |
t |
Optional (additional parameter) |
The user's security token |
Follow-up Operations
You can click More > Copy Path in the Operation column to copy the path of the folder and share it with others. Then they can open the bucket where the folder is stored and enter the path in the search box above the object list to find the folder.