Buckets are containers for objects. Before you upload an object to Object Storage Service (OSS), you must create a bucket to store the object. You can configure various attributes for a bucket, including the region, permissions, and storage class. You can create buckets of different storage classes to store your data.

Usage notes

  • When you create a bucket, you are charged only for the storage of objects in the bucket and the traffic generated when the objects are accessed. For more information, see Billing overview.
  • The capacity of a bucket is scalable. You do not need to purchase the capacity before you use the bucket.

Limits

  • You can use an Alibaba Cloud account to create up to 100 buckets in the same region.
  • After a bucket is created, its name, region, storage class, and redundancy type cannot be modified.
  • OSS does not impose limits on the capacity of a bucket.

Use the OSS console

  1. Log on to the OSS console.
  2. In the left-side navigation pane, click Buckets. On the Buckets page, click Create Bucket.
  3. In the Create Bucket panel, configure the parameters. The following table describes the parameters.
    ParameterRequiredDescription
    Bucket NameYesSpecify the name of the bucket that you want to create. The name of a bucket must meet the following conventions:
    • The name must be globally unique in OSS.
    • The name can contain only lowercase letters, digits, and hyphens (-).
    • The name must start and end with a lowercase letter or a digit.
    • The bucket name must be 3 to 63 characters in length.
    RegionYesThe region in which the bucket is located.

    To access OSS from an Elastic Compute Service (ECS) instance over an internal network, select the region in which the ECS instance is located. For more information, see OSS domain names.

    Note Before you create a bucket in a region in the Chinese mainland, you must complete real-name registration on the Real-name Registration page.
    EndpointYesThe public endpoint of the region in which the bucket is located.
    Resource GroupNoThe resource group to which the bucket belongs.
    Storage ClassYesThe storage class of the bucket.
    • Standard: provides highly reliable, highly available, and high-performance storage services that can handle frequent data access. Standard storage is suitable for images that are used for social networking and sharing applications, and data of audio and video applications, large websites, and big data analysis.
    • IA: provides highly durable storage services at lower prices compared with Standard storage. Infrequent Access (IA) objects have a minimum storage period of 30 days and a minimum billable size of 64 KB. IA storage is suitable for data that is infrequently accessed, such as once or twice a month. You can access IA objects in real time. You are charged data retrieval fees when you access IA objects.
    • Archive: provides highly durable storage services at lower prices compared with Standard storage and IA storage. Archive objects have a minimum storage period of 60 days and a minimum billable size of 64 KB. You must restore an Archive object before you can access it. The amount of time that is required to restore an Archive object is approximately one minute. You are charged data retrieval fees when you restore Archive objects. Archive storage is suitable for data that needs to be stored for a long period of time, such as archival data, medical images, scientific materials, and video footage.
    • Cold Archive: provides highly durable storage services at lower prices compared with Standard storage, IA storage, and Archive storage. Cold Archive objects have a minimum storage period of 180 days and a minimum billable size of 64 KB. You must restore a Cold Archive object before you can access it. The amount of time that is required to restore a Cold Archive object varies based on the object size and the restoration mode. You are charged data retrieval fees when you restore Cold Archive objects. Cold Archive storage is suitable for cold data that needs to be stored for an ultra-long period of time, including data that must be retained for an extended period of time to meet compliance requirements, raw data that is accumulated over an extended period of time in the big data and AI fields, retained media resources in the film and television industries, and archived videos in the online education industry.
      Note

      Cold Archive storage is supported in the following regions: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), China (Hong Kong), US (Silicon Valley), US (Virginia), Japan (Tokyo), Singapore, Australia (Sydney), Malaysia (Kuala Lumpur), Indonesia (Jakarta), Philippines (Manila), India (Mumbai), Germany (Frankfurt), UK (London), and UAE (Dubai).

    For more information about storage classes, see Overview.

    RedundancyYesThe redundancy type of the bucket. Valid values:
    • LRS

      Locally redundant storage (LRS) uses the single-zone mechanism to distribute user data on multiple devices of different facilities in one zone. This ensures data durability and availability even if hardware failures occur.

    • ZRS (Recommended)

      ZRS uses the multi-zone mechanism to distribute user data across multiple zones in the same region. If one zone becomes unavailable, you can continue to access the data that is stored in other zones.

      Important Zone-redundant storage (ZRS) is supported in the following regions: China (Shenzhen), China (Beijing), China (Hangzhou), China (Shanghai), China (Hong Kong), Singapore, and Indonesia (Jakarta). You are charged additional fees for ZRS. This feature cannot be disabled after it is enabled. Exercise caution when you enable this feature.

      For more information about zone-redundant storage, see ZRS.

    OSS HDFSNoIf you want to access OSS by using JindoSDK to build a data lake, you can enable OSS-HDFS. Before you enable OSS-HDFS, you must click Authorize and follow the on-screen instructions in the panel to grant RAM users the permissions to access OSS-HDFS.
    Important
    • OSS-HDFS is available in the following regions: China (Hangzhou), China (Shanghai), China (Shenzhen), China (Beijing), China (Zhangjiakou), and Singapore. If you want to enable OSS-HDFS, contact technical support. OSS-HDFS cannot be disabled after it is enabled. Exercise caution when you enable OSS-HDFS.
    • OSS-HDFS cannot be enabled for Archive or Cold Archive buckets.
    VersioningNoSpecifies whether to enable versioning.
    • Activate: If you enable versioning for a bucket, objects that are overwritten or deleted in the bucket are stored as previous versions. Versioning allows you to restore objects in the bucket to a previous version and protects your data from being accidentally overwritten or deleted. For more information, see Overview.
    • Not Activated: If you do not enable versioning for a bucket, you cannot restore objects that are overwritten or deleted in the bucket.
    Access Control List (ACL)YesThe ACL of a bucket. Valid values:
    • Private: Only the bucket owner can perform read and write operations on objects in the bucket. Other users cannot access the objects in the bucket.
    • Public Read: Only the bucket owner can perform write operations on objects in the bucket. All users, including anonymous users, can perform only read operations on the objects in the bucket.
      Warning If you set the ACL of a bucket to this value, all users can access the objects in the bucket over the Internet. This may result in unexpected access to the data in your bucket, and you may be charged unexpected fees. Exercise caution when you set the ACL of a bucket to Public Read.
    • Public Read/Write: All users, including anonymous users, can perform read and write operations on the objects in the bucket.
      Warning If you set the ACL of a bucket to this value, all users can access the objects in the bucket and write data to the bucket over the Internet. This may result in unexpected access to the data in your bucket, and you may be charged unexpected fees. If a user uploads prohibited data or information to your bucket, your legitimate rights and interests may be infringed. We recommend that you do not set the bucket ACL to Public Read/Write unless necessary.
    Encryption MethodNoSpecifies whether to enable server-side encryption for the bucket.
    Note Server-side encryption is available in the following regions: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), China (Hong Kong), US (Silicon Valley), US (Virginia), Japan (Tokyo), South Korea (Seoul), Singapore, Australia (Sydney), Malaysia (Kuala Lumpur), Indonesia (Jakarta), Philippines (Manila), Thailand (Bangkok), India (Mumbai), Germany (Frankfurt), UK (London), and UAE (Dubai).
    • Encryption Method: Select an encryption method for the bucket.
      • None: Server-side encryption is disabled.
      • OSS-Managed: Keys managed by OSS are used to encrypt objects in the bucket. OSS uses keys to encrypt objects. In addition, OSS uses regularly rotated master keys to encrypt cryptographic keys.
      • KMS: The default CMK stored in KMS or the specified CMK is used to encrypt and decrypt data.

        Before you can use KMS-managed keys, you must activate KMS. For more information, see Purchase a dedicated KMS instance.

    • Encryption Algorithm: Only AES-256 is supported.
    • CMK: You can set this parameter if Encryption Method is set to KMS. The following list describes the available options:
      • alias/acs/oss: The default CMK stored in KMS is used to generate different keys to encrypt objects and decrypt objects when the objects are downloaded.
      • CMK ID: The keys generated by a specified CMK are used to encrypt different objects and the specified CMK ID is recorded in the metadata of objects. Objects are decrypted when they are downloaded by users who are granted decryption permissions. Before you specify a CMK ID, you must create a normal key or an external key in the same region as the bucket in the KMS console. For more information, see Create a CMK.
    Real-time Log QueryNoIf you want to query OSS access logs of the previous seven days free of charge, click Activate.

    For more information, see Real-time log query.

    If you do not want to query real-time logs, retain the default configurations, which is Not Activated.

    Scheduled BackupNoIf you want to periodically back up your OSS data, click Activate. OSS automatically creates a backup plan to back up data once a day by using Hybrid Backup Recovery (HBR). The generated backups are stored for one week.
    Important
    • The scheduled backup feature is supported only in the following regions: China (Hangzhou), China (Shanghai), China (Shenzhen), China (Beijing), China (Zhangjiakou), China (Hong Kong), Singapore, Australia (Sydney), Indonesia (Jakarta), and US (Silicon Valley).
    • Scheduled backup cannot be configured for buckets whose storage classes are Archive or Cold Archive.
    • Backup and restoration of symbolic links, Archive and Cold Archive objects, and the access control lists (ACLs) of objects are not supported.
    • If HBR is not activated or HBR is not authorized to access OSS, a scheduled backup plan cannot be created.

    For more information, see Configure scheduled backup.

    If you do not want to periodically back up your OSS data, retain the default configurations, which is Not Activated.

    Hierarchical NamespaceNoIf you want to rename a directory or an object, enable the hierarchical namespace feature for the bucket in which the directory or object is stored.
    Important You can enable the hierarchical namespace feature for a bucket only when you create the bucket. The hierarchical namespace feature cannot be disabled after it is enabled for a bucket. After you enable this feature for a bucket, specific features of OSS become unavailable for the bucket. For more information about the features that are not supported for a bucket for which the hierarchical namespace feature is enabled, see Hierarchical namespace.
  4. Click OK.

Use ossbrowser

You can use ossbrowser to perform the same bucket-level operations that you can perform in the OSS console. You can follow the on-screen instructions in ossbrowser to create a bucket. For more information about how to use ossbrowser, see Use ossbrowser.

Use OSS SDKs

The following code provides examples on how to create a bucket by using OSS SDKs for common programming languages. For more information about how to create a bucket by using OSS SDKs for other programming languages, see Overview.

 // Create an OSSClient instance. 
 OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

 // Create the bucket and enable the hierarchical namespace feature for the bucket. 
 CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName).withHnsStatus(HnsStatus.Enabled);
 // The following code provides an example on how to specify the storage class, access control list (ACL), and redundancy type of the bucket that you want to create. 
 // In this example, the storage class of the bucket is set to Standard. 
 createBucketRequest.setStorageClass(StorageClass.Standard);
 // By default, the redundancy type of a bucket is set to DataRedundancyType.LRS, which indicates locally redundant storage (LRS). 
 createBucketRequest.setDataRedundancyType(DataRedundancyType.LRS);
 // Set the ACL of the bucket to public-read. The default value is private. 
 createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead);
 ossClient.createBucket(createBucketRequest);

 // Shut down the OSSClient instance. 
 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;

// 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. 
$accessKeyId = "yourAccessKeyId";
$accessKeySecret = "yourAccessKeySecret";
// In this example, the endpoint of the China (Hangzhou) region is used. Specify your actual endpoint. 
$endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
// Specify the name of the bucket. Example: examplebucket. 
$bucket= "examplebucket";
try {
    $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
    // Set the storage class of the bucket to Infrequent Access (IA). The default value is Standard. 
    $options = array(
        OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_IA
    );
    // Set the access control list (ACL) of the bucket to public-read. The default value is private. 
    $ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ, $options);
} catch (OssException $e) {
    printf(__FUNCTION__ . ": FAILED\n");
    printf($e->getMessage() . "\n");
    return;
}
print(__FUNCTION__ . ": OK" . "\n");        
const OSS = require('ali-oss');

const client = new OSS({
  // Set yourregion to the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set yourregion to oss-cn-hangzhou. 
  region: 'yourregion',
  // 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. 
  accessKeyId: 'yourAccessKeyId',
  accessKeySecret: 'yourAccessKeySecret'
});

// Create the bucket. 
async function putBucket() {
  try {
    const options = {
      storageClass: 'Standard', // By default, the storage class of a bucket is Standard. To set the storage class of the bucket to Archive, set storageClass to Archive. 
      acl: 'private', // By default, the ACL of a bucket is private. To set the ACL of the bucket to public read, set acl to public-read. 
      dataRedundancyType: 'LRS' // By default, the data redundancy type of a bucket is locally redundant storage (LRS). To set the data redundancy type of the bucket to zone-redundant storage (ZRS), set dataRedundancyType to ZRS. 
    }
    // Specify the bucket name. 
    const result = await client.putBucket('examplebucket', options);
    console.log(result);
  } catch (err) {
    console.log(err);
  }
}

putBucket();        
# -*- coding: utf-8 -*-
import oss2

# 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 operations and maintenance. 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, 'https://oss-cn-hangzhou.aliyuncs.com', 'examplebucket')

# Create the bucket. 
# The following code provides an example on how to specify the storage class, access control list (ACL), and redundancy type when you create a bucket. 
# In this example, the storage class is Standard, the ACL is private, and the redundancy type is zone-redundant storage (ZRS). 
# bucketConfig = oss2.models.BucketCreateConfig(oss2.BUCKET_STORAGE_CLASS_STANDARD, oss2.BUCKET_DATA_REDUNDANCY_TYPE_ZRS)
# bucket.create_bucket(oss2.BUCKET_ACL_PRIVATE, bucketConfig)
bucket.create_bucket()
using Aliyun.OSS;

// 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. 
var 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 operations and maintenance. To create a RAM user, log on to the RAM console. 
var accessKeyId = "yourAccessKeyId";
var accessKeySecret = "yourAccessKeySecret";
// Specify the name of the bucket. 
var bucketName = "examplebucket";

// Initialize an OSSClient instance. 
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);
// Create the bucket. 
try
    {
        var request = new CreateBucketRequest(bucketName);
        // Set the access control list (ACL) of the bucket to public-read (PublicRead). The default value is private. 
        request.ACL = CannedAccessControlList.PublicRead;
        // Set the redundancy type of the bucket to zone-redundant storage (ZRS). 
        request.DataRedundancyType = DataRedundancyType.ZRS;
        client.CreateBucket(request);
        Console.WriteLine("Create bucket succeeded");
    }
    catch (Exception ex)
    {
        Console.WriteLine("Create bucket failed. {0}", ex.Message);
    }
// Construct a request to create a bucket. 
// Specify the name of the bucket. 
CreateBucketRequest createBucketRequest = new CreateBucketRequest("examplebucket");
// Set the region in which the bucket is located to the China (Hangzhou) region. 
CreateBucketRequest.setLocationConstraint("oss-cn-hangzhou");
// Specify the access control list (ACL) of the bucket. 
// CreateBucketRequest.setBucketACL(CannedAccessControlList.Private);
// Specify the storage class of the bucket. 
// CreateBucketRequest.setBucketStorageClass(StorageClass.Standard);

// Create the bucket asynchronously. 
OSSAsyncTask createTask = oss.asyncCreateBucket(createBucketRequest, new OSSCompletedCallback<CreateBucketRequest, CreateBucketResult>() {
    @Override
    public void onSuccess(CreateBucketRequest request, CreateBucketResult result) {
        Log.d("asyncCreateBucket", "Success");
    }
    @Override
    public void onFailure(CreateBucketRequest request, ClientException clientException, ServiceException serviceException) {
        // Handle request exceptions. 
        if (clientException != null) {
            // Handle client exceptions, such as network exceptions. 
            clientException.printStackTrace();
        }
        if (serviceException != null) {
            // Handle service exceptions. 
            Log.e("ErrorCode", serviceException.getErrorCode());
            Log.e("RequestId", serviceException.getRequestId());
            Log.e("HostId", serviceException.getHostId());
            Log.e("RawMessage", serviceException.getRawMessage());
        }
    }
});
package main

    import (
        "fmt"
        "os"
        "github.com/aliyun/aliyun-oss-go-sdk/oss"
    )

func main() {
    // Create an OSSClient instance. 
    // 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 endpoint based on your business requirements. 
    // 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 operations and maintenance. 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)
    }

    // Create a bucket named examplebucket of which the storage class is IA (oss.StorageIA), the access control list (ACL) is public-read (oss.ACLPublicRead), and the redundancy type is zone-redundant storage (oss. Redundant ZRS). 
    err = client.CreateBucket("examplebucket", oss.StorageClass(oss.StorageIA), oss.ACL(oss.ACLPublicRead), oss.RedundancyType(oss.RedundancyZRS))
    if err != nil {
        fmt.Println("Error:", err)
        os.Exit(-1)
    }
}
id<OSSCredentialProvider> credentialProvider = [[OSSAuthCredentialProvider alloc] initWithAuthServerUrl:@"<StsServer>"];
OSSClientConfiguration *cfg = [[OSSClientConfiguration alloc] init];
cfg.maxRetryCount = 3;
cfg.timeoutIntervalForRequest = 15;

// If an OSSClient is released, all tasks in the session are canceled and the session becomes invalid. Make sure that the OSSClient is not released before the request is complete. 
// Set Endpoint 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 Endpoint to https://oss-cn-hangzhou.aliyuncs.com. 
OSSClient *client = [[OSSClient alloc] initWithEndpoint:@"Endpoint" credentialProvider:credentialProvider clientConfiguration:cfg];

OSSCreateBucketRequest * create = [OSSCreateBucketRequest new];
// Set the bucket name to examplebucket. 
create.bucketName = @"examplebucket";
// Set the access control list (ACL) of the bucket to private. 
create.xOssACL = @"private";
// Set the storage class of the bucket to Infrequent Access (IA). 
create.storageClass = OSSBucketStorageClassIA;

OSSTask * createTask = [client createBucket:create];

[createTask continueWithBlock:^id(OSSTask *task) {
    if (!task.error) {
        NSLog(@"create bucket success!");
    } else {
        NSLog(@"create bucket failed, error: %@", task.error);
    }
    return nil;
}];            
#include <alibabacloud/oss/OssClient.h>
using namespace AlibabaCloud::OSS;

int main(void)
{
    /* Initialize the account information. */
    /* 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 operations and maintenance. 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 yourEndpoint to https://oss-cn-hangzhou.aliyuncs.com. */
    std::string Endpoint = "yourEndpoint";
    /* Specify the name of the bucket. Example: examplebucket. */
    std::string BucketName = "examplebucket";

    /* Initialize resources such as network resources. */
    InitializeSdk();

    ClientConfiguration conf;
    OssClient client(Endpoint, AccessKeyId, AccessKeySecret, conf);

    /*Specify the name, storage class, and access control list (ACL) of the bucket. */
    CreateBucketRequest request(BucketName, StorageClass::IA, CannedAccessControlList::PublicReadWrite);
    /* Set the redundancy type of the bucket to zone-redundant storage (ZRS). */
    //request.setDataRedundancyType(DataRedundancyType::ZRS);

    /* Create the bucket. */
    auto outcome = client.CreateBucket(request);

    if (!outcome.isSuccess()) {
        /* Handle exceptions. */
        std::cout << "CreateBucket fail" <<
        ",code:" << outcome.error().Code() <<
        ",message:" << outcome.error().Message() <<
        ",requestId:" << outcome.error().RequestId() << std::endl;
        return -1;
    }

    /* Release resources such as network resources. */
    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 bucket name. Example: examplebucket. */
const char *bucket_name = "examplebucket";
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 to access OSS. A 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 indicates that the pool does not inherit other memory pools. */
    aos_pool_create(&pool, NULL);
    /* Create and initialize options. This parameter specifies global configuration information such as endpoint, access_key_id, access_key_secret, is_cname, and curl. */
    oss_request_options_t *oss_client_options;
    /* Allocate the memory resources in the memory pool to the options. */
    oss_client_options = oss_request_options_create(pool);
    /* Initialize oss_client_options. */
    init_options(oss_client_options);
    /* Initialize the parameters. */
    aos_string_t bucket;
    oss_acl_e oss_acl = OSS_ACL_PRIVATE;
    aos_table_t *resp_headers = NULL; 
    aos_status_t *resp_status = NULL; 
    /* Assign char* data to a bucket of the aos_string_t type.  */
    aos_str_set(&bucket, bucket_name);
    /* Create the bucket. */
    resp_status = oss_create_bucket(oss_client_options, &bucket, oss_acl, &resp_headers);
    /* Determine whether the bucket is created.  */
    if (aos_status_is_ok(resp_status)) {
        printf("create bucket succeeded\n");
    } else {
        printf("create bucket failed\n");
    }
    /* Release the memory pool. This operation releases the 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(
  # In this example, the endpoint of the China (Hangzhou) region is used. Specify your actual endpoint. 
  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 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. 
  access_key_id: 'AccessKeyId', access_key_secret: 'AccessKeySecret')
# Specify the bucket name. Example: examplebucket. 
client.create_bucket('examplebucket')

Use ossutil

For more information about how to create a bucket by using ossutil, see mb (create buckets).

Use RESTful APIs

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 PutBucket.

References

  • Object management
    • Upload objects

      After you create a bucket, you can upload objects to the bucket. For more information about how to upload objects, see Simple upload.

    • Download objects

      After you upload objects to a bucket, you can download the objects to the default download path of your browser or the specified local path. For more information about how to download objects, see Simple download.

    • Share objects

      You can share the URLs of uploaded objects with third parties for downloads or previews. For more information about how to share objects, see Share objects.

  • Access control

    By default, the ACL of OSS resources is private to ensure data security. Only the owners of the resources and authorized users can access the resources. OSS allows you to configure various policies to grant third-party users the specific permissions to access or use your OSS resources. For more information about access control, see Overview.