PUT Bucket

Last updated: 2021-08-12 10:11:05

    Overview

    This API is used to create a bucket under a specified account. A signature needs to be carried in Authorization and anonymous calls are not supported. By default, the bucket creator is the bucket owner.

    Note:

    • If no access permission is specified for a bucket when it is created, private (private read/write) will be used by default.
    API Explorer is recommended.
    Debug
    API Explorer makes it easy to make online API calls, verify signatures, generate SDK code, search for APIs, etc. You can also use it to query the content of each request as well as its response.

    Request

    Sample requests

    Sample 1

    PUT / HTTP/1.1
    Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
    Date: GMT Date
    Content-Length: 0
    Authorization: Auth String
    

    Sample 2

    PUT / HTTP/1.1
    Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
    Date: GMT Date
    Content-Type: application/xml
    Content-Length: Content Length
    Content-MD5: MD5
    Authorization: Auth String
    [Request Body]
    
    Note:

    Authorization: Auth String (See Request Signature for details.)

    Request parameters

    This API has no request parameter.

    Request headers

    In addition to common request headers, this API also supports the following request headers. For more information about common request headers, please see Common Request Headers.

    Header Description Type Required
    x-cos-acl Defines the access control list (ACL) attribute of the bucket. For the enumerated values such as private (default) and public-read, please see the Preset ACL section in ACL Overview. Enum No
    x-cos-grant-read Grants a user permission to read the bucket in the format of id="[OwnerUin]" (e.g., id="100000000001"). You can use a comma (,) to separate multiple users, for example, id="100000000001",id="100000000002". string No
    x-cos-grant-write Grants a user permission to write to the bucket in the format of id="[OwnerUin]" (e.g., id="100000000001"). You can use a comma (,) to separate multiple users, for example, id="100000000001",id="100000000002". string No
    x-cos-grant-read-acp Grants a user permission to read the ACL and policies of the bucket in the format of id="[OwnerUin]" (e.g., id="100000000001"). You can use a comma (,) to separate multiple users, for example, id="100000000001",id="100000000002". string No
    x-cos-grant-write-acp Grants a user permission to write to the ACL and policies of a bucket in the format of id="[OwnerUin]" (e.g., id="100000000001"). You can use a comma (,) to separate multiple users, for example, id="100000000001",id="100000000002". string No
    x-cos-grant-full-control Grants a user full permission to operate on the bucket in the format of id="[OwnerUin]" (e.g., id="100000000001"). You can use a comma (,) to separate multiple users, for example, id="100000000001",id="100000000002". string No

    Response

    Response headers

    This API returns only common response headers. For more information, please see Common Response Headers.

    Response body

    The response body of this API is empty.

    Error codes

    This API returns common error responses and error codes. For more information, please see Error Codes.

    Samples

    Sample 1. Setting public-read and granting a user permissions to write to the bucket and read the bucket ACL and policies

    Request

    PUT / HTTP/1.1
    Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
    Date: Fri, 14 Jun 2019 13:48:59 GMT
    x-cos-acl: public-read
    x-cos-grant-write: id="100000000002"
    x-cos-grant-read-acp: id="100000000002"
    Content-Length: 0
    Authorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO****&q-sign-time=1560520139;1560527339&q-key-time=1560520139;1560527339&q-header-list=content-length;date;host;x-cos-acl;x-cos-grant-read-acp;x-cos-grant-write&q-url-param-list=&q-signature=df03e7917270e0bf2b679bc6f99793bd0c63****
    Connection: close
    

    Response

    HTTP/1.1 200 OK
    Content-Length: 0
    Connection: close
    Date: Fri, 14 Jun 2019 13:49:00 GMT
    Server: tencent-cos
    x-cos-request-id: NWQwM2E1Y2NfZjBhODBiMDlfOTM1YV83NDRi****