PutBucketCORS
- Print
- PDF
PutBucketCORS
- Print
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
The latest service changes have not yet been reflected in this content. We will update the content as soon as possible. Please refer to the Korean version for information on the latest updates.
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 name | Requirement status | Type | Restrictions | Description |
---|---|---|---|---|
MaxAgeSeconds | No | string | For pre-flight OPTIONS requests for the specified resource, the meaning of the maximum response time (unit: second(s)) | |
ExposeHeader | No | string | Definition 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?