Object Storage Service (OSS) uses object metadata to describe object attributes. Object metadata includes standard HTTP headers and user metadata. You can configure HTTP headers to customize HTTP request policies, such as cache policies and policies for forced object download. You can also configure user metadata to identify the purposes or attributes of objects.
Standard HTTP headers
OSS retains standard HTTP headers for each object that is uploaded to buckets. The following table describes the standard HTTP headers.
Standard HTTP header | Description |
---|---|
Content-Type | The content type of the object. The browser determines the format and encoding type
that are used to read the object based on the content type of the object. If this
header is not specified, the value is generated based on the extension of the object
name. If the object name does not have an extension, the default value application/octet-stream is used as the content type of the object. For more information about how to set
the content type of an object, see How do I configure the Content-Type of objects?.
|
Content-Encoding | The encoding method of the object. Default value: identity. You must configure this
header based on the encoding type of the object. Otherwise, the browser that serves
as the client may fail to parse the encoding type of the object, or the object may
fail to be downloaded. If the object is not encoded, leave this header empty. Valid
values:
For more information about Content-Encoding, see RFC 2616. Notice If you want the static web page objects, such as HTML, JavaScript, XML, and JSON objects
to be compressed into GZIP objects when you access these objects, you must leave this
header empty and add the
Accept-Encoding: gzip header to your request.
|
Content-Language | The language of the object content. For example, if the content of an object is written in simplified Chinese, you can set this header to zh-CN. |
Content-Disposition | The method used to access the object. Valid values:
For more information about Content-Disposition, see RFC 2616. |
Cache-Control | The caching behavior for the object. Valid values:
|
Expires | The expiration time of the cache in Greenwich Mean Time (GMT). Example: 2022-10-12T00:00:00.000Z . If Cache-Control is set to max-age=<seconds> , max-age=<seconds> takes precedence over the value of Expires.
|
Last-Modified | The time when the object is last modified. |
Content-Length | The size of the object. Unit: bytes. |
User metadata
When you upload an object, you can add user metadata to identify the purposes or attributes of the object.
- You can configure multiple user metadata headers for an object. However, the total size of the user metadata of an object cannot exceed 8 KB.
- User metadata is a set of key-value pairs. The name of a user metadata header must
start with
x-oss-meta-
.x-oss-meta-last-modified:20210506
means that the local file was last modified on May 6, 2021. - When you call the GetObject operation or the HeadObject operation, the user metadata of the object is returned as HTTP headers.
Use the OSS console
You can configure object metadata for up to 100 objects at a time in the OSS console.
Use ossbrowser
You can use ossbrowser to perform the same object-level operations that you can perform in the OSS console. You can follow the on-screen instructions in ossbrowser to configure object metadata. For more information about how to use ossbrowser, see Use ossbrowser.
Use OSS SDKs
The following code provides examples on how to configure object metadata by using OSS SDKs for common programming languages. For more information about how to configure object metadata by using OSS SDKs for other programming languages, see Overview.
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.common.utils.BinaryUtil;
import com.aliyun.oss.common.utils.DateUtil;
import com.aliyun.oss.model.ObjectMetadata;
import java.io.ByteArrayInputStream;
public class Demo {
public static void main(String[] args) throws Exception {
// In this example, the endpoint of the China (Hangzhou) region is used. Specify your actual endpoint.
String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
// The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in Object Storage Service (OSS) is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console.
String accessKeyId = "yourAccessKeyId";
String accessKeySecret = "yourAccessKeySecret";
// Specify the bucket name. Example: examplebucket.
String bucketName = "examplebucket";
// Specify the full path of the object. The full path of the object cannot contain the bucket name. Example: testfolder/exampleobject.txt.
String objectName = "testfolder/exampleobject.txt";
String content = "Hello OSS";
// Create an OSSClient instance.
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
try {
// Create the metadata of the object. You can configure the HTTP headers of the object in the object metadata.
ObjectMetadata meta = new ObjectMetadata();
String md5 = BinaryUtil.toBase64String(BinaryUtil.calculateMd5(content.getBytes()));
// Enable MD5 verification. After MD5 verification is enabled, OSS calculates the MD5 hash of the object and compares this MD5 hash with the MD5 hash provided in the request. If the two values are different, an error occurs.
meta.setContentMD5(md5);
// Specify the type of the content that you want to upload. The browser determines the format and encoding type that are used to read the object based on the content type of the object. If the content type is not specified, a content type is generated based on the object name extension. If no extension is available, the default value application/octet-stream is used as the content type.
meta.setContentType("text/plain");
// Specify a name for the object when the content is downloaded.
meta.setContentDisposition("attachment; filename=\"DownloadFilename\"");
// Specify the length of the object content to upload. If the actual object length is greater than the configured length, the object is truncated. Only content of the configured length is uploaded. If the configured length is greater than the actual object length, all parts of the object are uploaded.
meta.setContentLength(content.length());
// Specify the caching behavior of the website when the content is downloaded.
meta.setCacheControl("Download Action");
// Specify the expiration time of the cache in GMT.
meta.setExpirationTime(DateUtil.parseIso8601Date("2022-10-12T00:00:00.000Z"));
// Specify the content encoding format when the content is downloaded.
meta.setContentEncoding("utf-8");
// Configure the HTTP header.
meta.setHeader("yourHeader", "yourHeaderValue");
// Upload the object.
ossClient.putObject(bucketName, objectName, new ByteArrayInputStream(content.getBytes()), meta);
} catch (OSSException oe) {
System.out.println("Caught an OSSException, which means your request made it to OSS, "
+ "but was rejected with an error response for some reason.");
System.out.println("Error Message:" + oe.getErrorMessage());
System.out.println("Error Code:" + oe.getErrorCode());
System.out.println("Request ID:" + oe.getRequestId());
System.out.println("Host ID:" + oe.getHostId());
} catch (ClientException ce) {
System.out.println("Caught an ClientException, which means the client encountered "
+ "a serious internal problem while trying to communicate with OSS, "
+ "such as not being able to access the network.");
System.out.println("Error Message:" + ce.getMessage());
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
}
}
<?php
if (is_file(__DIR__ . '/../autoload.php')) {
require_once __DIR__ . '/../autoload.php';
}
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
}
use OSS\OssClient;
use OSS\Core\OssException;
// Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to access Object Storage Service (OSS) because the account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console.
$accessKeyId = "yourAccessKeyId";
$accessKeySecret = "yourAccessKeySecret";
// Set yourEndpoint to the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
$endpoint = "yourEndpoint";
// Specify the bucket name. Example: examplebucket.
$bucket= "examplebucket";
// Specify the full path of the object. The full path cannot contain the bucket name. Example: exampledir/exampleobject.txt.
$object = "exampledir/exampleobject.txt";
$content = file_get_contents(__FILE__);
$options = array(
OssClient::OSS_HEADERS => array(
'Expires' => '2012-10-01 08:00:00',
'Content-Disposition' => 'attachment; filename="xxxxxx"',
'x-oss-meta-self-define-title' => 'user define meta info',
));
try{
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
$ossClient->putObject($bucket, $object, $content, $options);
} catch(OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
let OSS = require('ali-oss')
let client = new OSS({
region: '<Your region>',
accessKeyId: '<Your AccessKeyId>',
accessKeySecret: '<Your AccessKeySecret>',
bucket: 'Your bucket name'
});
async function put () {
try {
let result = await client.put('object-name', 'local-file', {
meta: {
year: 2016,
people: 'mary'
}
});
console.log(result);
} catch (e) {
console.log(e);
}
}
put();
# -*- coding: utf-8 -*-
import oss2
# Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to access Object Storage Service (OSS) because the account has permissions on all API operations. We recommend that you use a Resource Access Management (RAM) user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console.
auth = oss2.Auth('yourAccessKeyId', 'yourAccessKeySecret')
# Set yourEndpoint to the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set yourEndpoint to https://oss-cn-hangzhou.aliyuncs.com.
# Specify the name of the bucket. Example: examplebucket.
bucket = oss2.Bucket(auth, 'yourEndpoint', 'examplebucket')
# Specify the full path of the object. Example: exampledir/exampleobject.txt. The full path of the object cannot contain the bucket name.
object_name = 'exampledir/exampleobject.txt'
# Specify the string to upload.
content = '{"age": 1}'
# Configure HTTP headers. For example, set the value of the header Content-Type to 'application/json; charset=utf-8'.
bucket.put_object(object_name, content, headers={'Content-Type': 'application/json; charset=utf-8'})
using Aliyun.OSS;
using Aliyun.OSS.Common;
// Set yourEndpoint to the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
var endpoint = "yourEndpoint";
// Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to access Object Storage Service (OSS) because the account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console.
var accessKeyId = "yourAccessKeyId";
var accessKeySecret = "yourAccessKeySecret";
// Specify the bucket name.
var bucketName = "examplebucket";
// Specify the full path of the object. The full path cannot contain the bucket name.
var objectName = "exampleobject.txt";
// Specify the full path of the local file that you want to upload. By default, if you do not specify the full path of the local file, the local file is uploaded from the path of the project to which the sample program belongs.
var localFilename = "D:\\localpath\\examplefile.txt";
// Create an OSSClient instance.
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
try
{
using (var fs = File.Open(localFilename, FileMode.Open))
{
// Create the metadata of the object. You can configure the HTTP headers of the object.
var metadata = new ObjectMetadata()
{
// Specify the object type.
ContentType = "text/html",
// Specify the expiration time of the cache in GMT.
ExpirationTime = DateTime.Parse("2025-10-12T00:00:00.000Z"),
};
// Specify the length of the object content to upload. If the actual object length is greater than the specified length, the object is uploaded based on the specified length. If the object is smaller than the specified length, the object is uploaded based on the actual length.
metadata.ContentLength = fs.Length;
// Specify the caching behavior of the website when the content is downloaded.
metadata.CacheControl = "No-Cache";
// Set the value of mykey1 for user metadata to myval1.
metadata.UserMetadata.Add("mykey1", "myval1");
// Set the value of mykey2 for user metadata to myval2.
metadata.UserMetadata.Add("mykey2", "myval2");
var saveAsFilename = "Filetest123.txt";
var contentDisposition = string.Format("attachment;filename*=utf-8''{0}", HttpUtils.EncodeUri(saveAsFilename, "utf-8"));
// Provide a default object name when the requested content is stored as a object.
metadata.ContentDisposition = contentDisposition;
// Upload the object and configure object metadata.
client.PutObject(bucketName, objectName, fs, metadata);
Console.WriteLine("Put object succeeded");
// Query object metadata.
var oldMeta = client.GetObjectMetadata(bucketName, objectName);
// Configure the metadata of the destination object.
var newMeta = new ObjectMetadata()
{
ContentType = "application/octet-stream",
ExpirationTime = DateTime.Parse("2035-11-11T00:00:00.000Z"),
// Specify the encoding format that is used when the object is downloaded.
ContentEncoding = null,
CacheControl = ""
};
// Configure user metadata.
newMeta.UserMetadata.Add("author", "oss");
newMeta.UserMetadata.Add("flag", "my-flag");
newMeta.UserMetadata.Add("mykey2", "myval2-modified-value");
// Modify object metadata by using the ModifyObjectMeta method.
client.ModifyObjectMeta(bucketName, objectName, newMeta);
}
}
catch (Exception ex)
{
Console.WriteLine("Put object failed, {0}", ex.Message);
}
// Create a request to obtain the metadata of an object by calling the synchronous interface.
HeadObjectRequest head = new HeadObjectRequest("<bucketName>", "<objectKey>");
// Obtain the metadata of an object.
OSSAsyncTask task = oss.asyncHeadObject(head, new OSSCompletedCallback<HeadObjectRequest, HeadObjectResult>() {
@Override
public void onSuccess(HeadObjectRequest request, HeadObjectResult result) {
// Obtain the size of the object.
Log.d("headObject", "object Size: " + result.getMetadata().getContentLength());
// Obtain the type of the object.
Log.d("headObject", "object Content Type: " + result.getMetadata().getContentType());
}
@Override
public void onFailure(HeadObjectRequest request, ClientException clientExcepion, ServiceException serviceException) {
// Handle the exceptions returned for the request.
if (clientExcepion != null) {
// A local exception (such as network exception) occurs.
clientExcepion.printStackTrace();
}
if (serviceException != null) {
// A service exception occurs.
Log.e("ErrorCode", serviceException.getErrorCode());
Log.e("RequestId", serviceException.getRequestId());
Log.e("HostId", serviceException.getHostId());
Log.e("RawMessage", serviceException.getRawMessage());
}
}
});
// task.waitUntilFinished(); // Wait until the task is complete.
package main
import (
"fmt"
"os"
"time"
"strings"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)
func main() {
// Create an OSSClient instance.
// Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com. Specify your actual endpoint.
// Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to access Object Storage Service (OSS) because the account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console.
client, err := oss.New("yourEndpoint", "yourAccessKeyId", "yourAccessKeySecret")
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Specify the bucket name. Example: examplebucket.
bucket, err := client.Bucket("examplebucket")
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Configure object metadata: Set the expiration time to 23:00:00 January 10, 2049 in GMT, access control list (ACL) to public read, and MyProp to MyPropVal as user metadata.
expires := time.Date(2049, time.January, 10, 23, 0, 0, 0, time.UTC)
options := []oss.Option{
oss.Expires(expires),
oss.ObjectACL(oss.ACLPublicRead),
oss.Meta("MyProp", "MyPropVal"),
}
// Use a data stream to upload the object.
// Specify the full path of the object. The full path cannot contain the bucket name. Example: exampledir/exampleobject.txt.
err = bucket.PutObject("exampledir/exampleobject.txt", strings.NewReader("MyObjectValue"), options...)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Query object metadata.
props, err := bucket.GetObjectDetailedMeta("exampledir/exampleobject.txt")
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
fmt.Println("Object Meta:", props)
}
OSSHeadObjectRequest * request = [OSSHeadObjectRequest new];
request.bucketName = @"<bucketName>;
//objectKey indicates the name of the object, that is, the complete path of the object. objectKey must include the file extension of the object. For example, set objectKey to abc/efg/123.jpg.
request.objectKey = @"<objectKey>";
OSSTask * headTask = [client headObject:request];
[headTask continueWithBlock:^id(OSSTask *task) {
if (! task.error) {
NSLog(@"head object success!") ;
OSSHeadObjectResult * result = task.result;
NSLog(@"header fields: %@", result.httpResponseHeaderFields);
for (NSString * key in result.objectMeta) {
NSLog(@"ObjectMeta: %@ - %@", key, [result.objectMeta objectForKey:key]);
}
} else {
NSLog(@"head object failed, error: %@" ,task.error);
}
return nil;
}];
#include <alibabacloud/oss/OssClient.h>
using namespace AlibabaCloud::OSS;
int main(void)
{
/* Initialize the information about the account that is used to access Object Storage Service (OSS). */
/* Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to access OSS because the account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. */
std::string AccessKeyId = "yourAccessKeyId";
std::string AccessKeySecret = "yourAccessKeySecret";
/* Set yourEndpoint to the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com. */
std::string Endpoint = "yourEndpoint";
/* Specify the bucket name. Example: examplebucket. */
std::string BucketName = "examplebucket";
/* Specify the full path of the object. The full path cannot contain the bucket name. Example: exampledir/exampleobject.txt. */
std::string ObjectName = "exampledir/exampleobject.txt";
/* Initialize resources such as networks. */
InitializeSdk();
ClientConfiguration conf;
OssClient client(Endpoint, AccessKeyId, AccessKeySecret , conf);
/* Specify the HTTP headers. */
auto meta = ObjectMetaData();
meta.setContentType("text/plain");
meta.setCacheControl("max-ag e=3");
/* Specify user metadata. */
meta.UserMetaData()["meta"] = "meta-value";
std::shared_ptr<std::iostream> content = std::make_shared<std::stringstream>();
*content << "Thank you for using Aliyun Object Storage Service!";
client.PutObject(BucketName, ObjectName, content, meta);
if (!outcome.isSuccess()) {
/* Handle exceptions. */
std::cout << "PutObject fail" <<
",code:" << outcome.error().Code() <<
",message:" << outcome.error().Message() <<
",requestId:" << outcome.error().RequestId() << std::endl;
ShutdownSdk();
return -1;
}
/* Release resources such as networks. */
ShutdownSdk();
return 0;
}
#include "oss_api.h"
#include "aos_http_io.h"
/* Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com. */
const char *endpoint = "yourEndpoint";
/* The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in OSS is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. */
const char *access_key_id = "yourAccessKeyId";
const char *access_key_secret = "yourAccessKeySecret";
/* Specify the name of the bucket. Example: examplebucket. */
const char *bucket_name = "examplebucket";
/* Specify the full path of the object. The path cannot contain the bucket name. Example: exampledir/exampleobject.txt. */
const char *object_name = "exampledir/exampleobject.txt";
void init_options(oss_request_options_t *options)
{
options->config = oss_config_create(options->pool);
/* Use a char* string to initialize the aos_string_t data type. */
aos_str_set(&options->config->endpoint, endpoint);
aos_str_set(&options->config->access_key_id, access_key_id);
aos_str_set(&options->config->access_key_secret, access_key_secret);
/* Specify whether to use CNAME. The value of 0 indicates that CNAME is not used. */
options->config->is_cname = 0;
/* Configure network parameters such as the timeout period. */
options->ctl = aos_http_controller_create(options->pool, 0);
}
int main(int argc, char *argv[])
{
/* Call the aos_http_io_initialize method in main() to initialize global resources such as networks and memory. */
if (aos_http_io_initialize(NULL, 0) != AOSE_OK) {
exit(1);
}
/* Create a memory pool to manage memory. aos_pool_t is equivalent to apr_pool_t. The code used to create a memory pool is included in the APR library. */
aos_pool_t *pool;
/* Create a memory pool. The value of the second parameter is NULL. This value specifies that the pool does not inherit other memory pools. */
aos_pool_create(&pool, NULL);
/* Create and initialize options. This parameter includes global configuration information such as endpoint, access_key_id, access_key_secret, is_cname, and curl. */
oss_request_options_t *oss_client_options;
/* Allocate memory resources in the memory pool to the options parameter. */
oss_client_options = oss_request_options_create(pool);
/* Initialize oss_client_options. */
init_options(oss_client_options);
/* Initialize the parameters. */
aos_string_t bucket;
aos_string_t object;
aos_table_t *headers;
aos_list_t buffer;
aos_table_t *resp_headers = NULL;
aos_status_t *resp_status = NULL;
aos_buf_t *content = NULL;
char *content_length_str = NULL;
char *object_type = NULL;
char *object_author = NULL;
int64_t content_length = 0;
aos_str_set(&bucket, bucket_name);
aos_str_set(&object, object_name);
headers = aos_table_make(pool, 2);
/* Configure user metadata. */
apr_table_set(headers, "Expires", "Fri, 28 Feb 2032 05:38:42 GMT");
apr_table_set(headers, "x-oss-meta-author", "oss");
aos_list_init(&buffer);
content = aos_buf_pack(oss_client_options->pool, object_content, strlen(object_content));
aos_list_add_tail(&content->node, &buffer);
/* Upload the object from the buffer. */
resp_status = oss_put_object_from_buffer(oss_client_options, &bucket, &object,
&buffer, headers, &resp_headers);
if (aos_status_is_ok(resp_status)) {
printf("put object from buffer with md5 succeeded\n");
} else {
printf("put object from buffer with md5 failed\n");
}
// Query the metadata of the object. */
resp_status = oss_get_object_meta(oss_client_options, &bucket, &object, &resp_headers);
if (aos_status_is_ok(resp_status)) {
content_length_str = (char*)apr_table_get(resp_headers, OSS_CONTENT_LENGTH);
if (content_length_str != NULL) {
content_length = atol(content_length_str);
}
object_author = (char*)apr_table_get(resp_headers, OSS_AUTHORIZATION);
object_type = (char*)apr_table_get(resp_headers, OSS_OBJECT_TYPE);
printf("get object meta succeeded, object author:%s, object type:%s, content_length:%ld\n", object_author, object_type, content_length);
} else {
printf("req:%s, get object meta failed\n", resp_status->req_id);
}
/* Release the memory pool, which releases memory resources allocated for the request. */
aos_pool_destroy(pool);
/* Release the allocated global resources. */
aos_http_io_deinitialize();
return 0;
}
require 'aliyun/oss'
client = Aliyun::OSS::Client.new(
# Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
endpoint: 'https://oss-cn-hangzhou.aliyuncs.com',
# Security risks may arise if you use the AccessKey pair of an Alibaba Cloud account to access OSS because the account has permissions on all API operations. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console.
access_key_id: 'AccessKeyId', access_key_secret: 'AccessKeySecret')
# Specify the bucket name. Example: examplebucket.
bucket = client.get_bucket('examplebucket')
bucket.put_object(
'my-object-1',
:file => 'local-file',
:metas => {'year' => '2016', 'people' => 'mary'})
bucket.append_object(
'my-object-2', 0,
:file => 'local-file',
:metas => {'year' => '2016', 'people' => 'mary'})
bucket.resumable_upload(
'my-object',
'local-file',
:metas => {'year' => '2016', 'people' => 'mary'})
Use ossutil
For more information about how to configure object metadata by using ossutil, see set-meta.
Use the RESTful API
If your business requires a high level of customization, you can directly call RESTful APIs. To directly call an API, you must include the signature calculation in your code. For more information, see PutObject.