PutBucketCORS
    • PDF

    PutBucketCORS

    • PDF

    Article Summary

    Overview

    Sending a PUT request to a bucket with the provided parameters creates a new cross-origin resource sharing (CORS) setting or edits the existing setting. Note that the SHA256 hash in the body should have an additional Content-MD5 header.

    Requests

    Syntax

    PUT https://{endpoint}/{bucket-name}?cors= # path style
    PUT https://{bucket-name}.{endpoint}?cors= # virtual host style
    

    Payload

    The XML block that defines the core components of CORS (AllowedOrigin, AllowedMethod) has two payload components.

    Component nameRequirement statusTypeRestrictionsDescription
    MaxAgeSecondsNostringFor pre-flight OPTIONS requests for the specified resource, the meaning of the maximum response time (unit: second(s))
    ExposeHeaderNostringDefinition of headers to be exposed to external applications

    Examples

    Request examples

    The following example requests the addition of CORS settings that allow requests from www.example.com so that GET, PUT, and POST requests can be sent to the bucket.

    PUT /apiary?cors= HTTP/1.1
    Authorization: {authorization-string}
    x-amz-date: 20161011T190354Z
    x-amz-content-sha256: 2938f51643d63c864fdbea618fe71b13579570a86f39da2837c922bae68d72df
    Content-MD5: FQXTKrg+IwERGnHEQcL0xg==
    Content-Type: text/plain
    Host: kr.object.ncloudstorage.com
    Content-Length: 237
    
    <?xml version="1.0" encoding="UTF-8"?>
    <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
        <CORSRule>
            <AllowedOrigin>http://www.example.com</AllowedOrigin>
            <AllowedMethod>POST</AllowedMethod>
            <AllowedMethod>GET</AllowedMethod>
            <AllowedMethod>PUT</AllowedMethod>
            <AllowedMethod>DELETE</AllowedMethod>
            <AllowedMethod>HEAD</AllowedMethod>
            <AllowedHeader>*</AllowedHeader>
            <ExposeHeader>ETag</ExposeHeader>
        </CORSRule>
    </CORSConfiguration>
    

    Response examples

    HTTP/1.1 200 OK
    Date: Wed, 5 Oct 2016 15:39:38 GMT
    Accept-Ranges: bytes
    x-amz-request-id: 7afca6d8-e209-4519-8f2c-1af3f1540b42
    Content-Length: 0
    

    Was this article helpful?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.