Obtaining Data Metadata
Overview
Object metadata refers to the attribute descriptions of files uploaded to BOS and is categorized into two types: system-defined metadata and user-defined metadata. Metadata can be configured during various upload methods or file copying processes.
System-defined Metadata
Each object is associated with a set of metadata. Metadata identifies the attributes of an object, such as the date and content length, which is used for object management.
System-defined metadata is further divided into two categories: modifiable by users and unmodifiable by users. Inherent attributes of an object, such as creation date, content length, last modification time, and MD5 checksum, are unmodifiable metadata. Attributes like Content-Type, Cache-Control, and storage-class can be modified by users when creating the object or as required. For a detailed description of system-defined metadata, please refer to the table below:
| Name | Type | Description | Whether it can be modified by users |
|---|---|---|---|
| Cache-Control | String | Cache settings for downloading the object. Common values include private, no-cache, max-age, must-revalidate. |
Yes |
| Content-Disposition | String | Specify whether the browser should download the file. Possible values are inline and attachment, e.g., filename="download.txt". | Yes |
| Content-MD5 | String | The MD5 checksum of the HTTP request content as defined in RFC 2616, used to ensure consistency between the file stored on BOS and the file expected by the user. | No |
| Content-Length | Long Int | The size of the data returned to the object. | No |
| Content-Type | String | The object's type and encoding method. | Yes |
| Expires | String | Set the cache expiration time when the object is downloaded. | Yes |
| ETag | String | The HTTP protocol entity tag of the object. | No |
| x-bce-storage-class | String | Standard storage returns STANDARD, infrequent access storage returns STANDARD_IA, cold storage returns COLD, and archive storage returns ARCHIVE. | No |
| x-bce-object-type | String | Determine whether an object is appendable or regular. Appendable objects can have data appended, while regular ones cannot. Archive storage does not support appendable objects. | No |
| x-bce-tagging-count | Long Int | Specify the number of tags associated with an object. | No |
User-defined metadata
Enable users to add additional descriptions to an object. In BOS, all parameters prefixed with x-bce-meta- are considered user-defined metadata, such as x-bce-meta-tag. An object can have multiple user-defined metadata entries, which will be returned in the HTTP header during downloads using GetObject or HeadObject.
Description:
- The size limit for the PUT request header is 8 KB. Within the PUT request header, user-defined metadata has a size limit of 2 KB.
Operation types
BOS supports obtaining object meta information through various SDKs, as follows:
- [Java SDK](BOS/SDK/Java-SDK/File management/Get and update file meta information.md)
- [Python SDK](BOS/SDK/Python-SDK/File management/Get and update file meta information.md)
- PHP SDK
- [C++ SDK](BOS/SDK/C++-SDK/File management/Get and update file meta information.md)
Example
Take the Java SDK as an example
1String EndPoint = "bj.bce.bos.com"
2public static void GetObjectMeta(BosClient bosClient, String bucketname, String objectkey)
3 {
4 ObjectMetadata objectMetadata;
5 objectMetadata = bosClient.getObjectMetadata(bucketname, objectkey);
6 System.out.println(objectMetadata.getContentType());
7 System.out.println(objectMetadata.getUserMetadata());
8 }
