Overview
An object (Object) is the fundamental unit of COS and can be defined as data in any format, such as images, documents, and audio-video files.
Preparations
2. Have operational permissions for the Tencent Cloud LighthouseCOS(LHCOS) service. The primary account has all permissions by default, while sub-accounts need to grant COS service permissions on demand via the CAM service. 3. You have created a bucket and have operational permissions for the bucket.
Uploading Files
2. On the bucket card page, click the bucket in which you want to store objects to go to the file list page of the bucket.
3. In the file list, click the Upload File button; in the pop-up window, after selecting the local file, click Upload.
Note:
Some browsers do not support uploading multiple files. It is recommended that you use mainstream browsers, such as Internet Explorer 10 or later, Firefox, and Chrome.
Downloading a File
2. On the bucket card page, click the bucket where the objects are located to go to the file list page of the bucket.
3. In the file list, locate the object to be downloaded, and click the Download button; in the pop-up window, click OK to download.
Note:
Downloading files will incur download traffic fees.
Deletes files
2. On the bucket card page, click the bucket where the objects are located to go to the file list page of the bucket.
3. In the file list, locate the object to be deleted, and click the Delete button; in the pop-up window, click OK to delete.
Note:
Once files are deleted, they cannot be recovered. Please exercise caution when performing deletion.
Share files
2. On the bucket card page, click the bucket where the objects are located to go to the file list page of the bucket.
3. In the file list, locate the object to be shared, and click More > Quick Share Link.
4. In the pop-up window, select the type of link to share, click Copy Link to share it.
Note:
Share links with signatures offer enhanced security and are valid for 2 hours by default. Share links without signatures cannot be accessed by anonymous users under private read-write settings.
Rename the file
2. On the bucket card page, click the bucket where the objects are located to go to the file list page of the bucket.
3. In the file list, locate the object to be renamed, and click More > Rename.
4. In the pop-up window, enter the new file name and click Confirm to complete the renaming.
Note:
Renaming needs to comply with file naming conventions. For details, see the instructions in the Notes section.
Moving a file
2. On the bucket card page, click the bucket where the objects are located to go to the file list page of the bucket.
3. In the file list, click More > Move.
4. In the pop-up window, select the target folder and click OK to complete the move.
Note:
If a file with the same name exists in the target folder, it will be overwritten. Proceed with caution and carefully evaluate before moving files.
Set file permissions
2. On the bucket card page, click the bucket where the objects are located to go to the file list page of the bucket.
3. In the file list, locate the object for which you need to set permissions, and click More > Set Permissions.
4. In the pop-up window, you can switch file permissions as needed.
Note:
By default, files inherit the bucket permissions. It is not recommended to set them to public read and private write, as this may lead to file hotlinking.
New folder
2. On the bucket card page, click the desired bucket to go to its file list.
3. In the file list, click the New Folder button; in the pop-up window, enter the folder name and click OK.
Note:
Folder naming must comply with the naming conventions. See the instructions in the following notes.
Delete file fragments
You can go to the File Fragments management item to view incomplete upload fragments and delete them.
Note:
During the object upload process, files that are paused or canceled will be displayed in the File Fragments management item. After the upload is completed, you can find the uploaded files in the File List.
File fragments occupy storage space just like regular objects, therefore incurring storage capacity costs.
2. On the bucket card page, click the bucket where you want to create a new folder to go to its file list page.
3. In the file list, click File Fragments to view incomplete upload fragments on the navigated File Fragments page.
4. Click Delete to the right of a file fragment to delete an incomplete upload fragment. You can also click Clear All Fragments at the top to delete all incomplete upload fragments with one click.
Must-Knows
Naming Conventions
File names in a bucket must comply with the corresponding naming conventions:
You can use any UTF-8 characters. To ensure maximum compatibility with other applications, it is recommended to use English letters (uppercase and lowercase), numbers [a-z, A-Z, 0-9], and combinations thereof.
The encoded length can be up to 850 bytes.
File names must not start with a forward slash / or a backslash \\.
The ASCII control characters for upward arrow (↑), downward arrow (↓), rightward arrow (→), and leftward arrow (←) are not supported. These correspond to CAN (24), EM (25), SUB (26), and ESC (27), respectively.
For special characters such as * and %, it is recommended to avoid using them directly in file names.
Note:
If the name of a file or folder uploaded by a user contains Chinese characters, when the file or folder is accessed or requested, the Chinese characters will be converted to percent-encoding according to URL Encode rules.
For example: when document.doc is accessed, the file name is: document.doc, and the actual percent-encoding read according to URL Encode rules is: %e6%96%87%e6%a1%a3.doc.
The following are examples of valid object key names:
doc/exampleobject
my.great_photos-2016/01/me.jpg
videos/2016/birthday/video.wmv
Special Characters
Certain characters in object keys may need to be URL-encoded or referenced in the hexadecimal format. Some of them are non-printable characters, and your browser may not be able to handle them, so they require special handling. Such characters may include:
, | : | ; | = |
& | $ | @ | + |
? | ASCII character ranges: 00–1F hexadecimal (0–31 decimal) and 7F (127 decimal) | (Space) |
|
Some characters require extensive special processing to maintain consistency across all applications and are therefore recommended to be avoided. Characters to avoid include:
` | ^ | " | \\ |
{ | } | [ | ] |
~ | % | # | | |
* | > | < | ASCII 128-255 decimal |
Access Address
The access address consists of the bucket access address and the file name, and its structure is <bucket domain>/<file name>.
For example: uploading a file exampleobject.txt to the bucket in Guangzhou (South China) examplebucket-1250000000, then the access address of exampleobject.txt is: examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/exampleobject.txt.
Folders and Directories
LHCOS does not inherently have the concept of folders or directories. Uploading an object project/a.txt does not create a project folder. To align with user habits, we simulate the display of "folders" or "directories" in graphical tools like the console. This is achieved by creating an object with a key value of project/ and empty content, mimicking traditional folders in its presentation.
For example, when you upload the object project/doc/a.txt via an API or SDK, the delimiter / simulates the display of folders, and you can see the "folders" project and doc in the console. The "folder" doc is displayed under the "folder" project and contains the file a.txt.
Note:
Objects in the bucket are evenly distributed among distributed clusters. Therefore, you cannot directly get the size of all objects with a specified object key prefix. Instead, you can accumulate the size of each object to get the full size.
Deleting folders and directories is relatively complicated, as detailed below:
|
Console | Folder project | All objects with the object key prefix project/ will be deleted. |
Console | File project/doc/a.txt | The project and doc folders will remain. |
API,SDK | File project/ or project/doc/ | The object project/doc/a.txt will still be retained. If you want to delete all objects within the folder, you need to use code to traverse and implement the feature of deleting files within the folder. |