upload method
Written by
Updated at August 2, 2024
Uploads a static website hosting configuration for a bucket.
Request
PUT /{bucket}?website HTTP/2
Path parameters
Parameter | Description |
---|---|
bucket |
Bucket name. |
Query parameters
Parameter | Description |
---|---|
website |
Required parameter that indicates the type of operation. |
Headers
Use the appropriate common headers in your requests.
Data schema
You can configure a bucket:
As a website
To redirect all requests
For conditionally redirecting requests
Configuration example:
<!--Website configuration-->
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<IndexDocument>
<Suffix>index.html</Suffix>
</IndexDocument>
<ErrorDocument>
<Key>Error.html</Key>
</ErrorDocument>
</WebsiteConfiguration>
Possible elements:
Element | Description |
---|---|
WebsiteConfiguration |
Top-level header of the website description. |
IndexDocument/Suffix |
The website homepage. Path: /WebsiteConfiguration/IndexDocument/Suffix . |
ErrorDocument/Key |
Document that the user sees if a 4xx error occurs.Path: /WebsiteConfiguration/ErrorDocument/Key . |
Configuration example:
<!--Configuration for redirecting all requests-->
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<RedirectAllRequestsTo>
<HostName>example.com</HostName>
<Protocol>http</Protocol>
</RedirectAllRequestsTo>
</WebsiteConfiguration>
Possible elements:
Element | Description |
---|---|
WebsiteConfiguration |
Top-level header of the website description. |
RedirectAllRequestsTo |
Contains a redirect configuration for all requests. Path: /WebsiteConfiguration/RedirectAllRequestsTo . |
HostName |
Host to which all requests to the bucket are redirected. Path: /WebsiteConfiguration/RedirectAllRequestsTo/HostName . |
Protocol |
Protocol used for redirects: http or https . Optional element.Path: /WebsiteConfiguration/RedirectAllRequestsTo/Protocol . |
Configuration example:
<!--Configuration for conditional redirect of all requests-->
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<IndexDocument>
<Suffix>index.html</Suffix>
</IndexDocument>
<ErrorDocument>
<Key>Error.html</Key>
</ErrorDocument>
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>k8s/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyPrefixWith>kubernetes/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
</WebsiteConfiguration>
Possible elements:
Element | Description |
---|---|
WebsiteConfiguration |
Top-level header of the website description. |
IndexDocument/Suffix |
Home page of the website. |
ErrorDocument/Key |
Document that the user sees if a 4xx error occurs. |
RoutingRules |
Routing rule container RoutingRule .It must include at least one rule. |
RoutingRule |
Routing rule. Defines the conditions and conditional redirects. |
Condition |
Container used for conditions that trigger the redirect. If a routing rule doesn't contain any conditions, all the requests are redirected. A container must include at least one rule. |
KeyPrefixEquals |
The condition sets the name prefix for the request-originating object.KeyPrefixEquals is required if HttpErrorCodeReturnedEquals is not set. If KeyPrefixEquals and HttpErrorCodeReturnedEquals are set, the condition is met when both the parameters are true . |
HttpErrorCodeReturnedEquals |
The condition specifies the error code that triggers a redirect.HttpErrorCodeReturnedEquals is required if KeyPrefixEquals is not set. If KeyPrefixEquals and HttpErrorCodeReturnedEquals are set, the condition is met when both the parameters are true . |
Redirect |
Redirect container. You can redirect a request to a different page, different host, or change the protocol. The RoutingRule rule must contain at least one Redirect element.A redirect must contain at least one of the following elements: Protocol , HostName , ReplaceKeyPrefixWith , ReplaceKeyWith , or HttpRedirectCode . |
Protocol |
In the Location response header, a redirect indicates the protocol scheme (http or https ) to be used.This parameter is optional if other redirects are used. |
HostName |
In the Location response header, a redirect indicates the host name to be used.This parameter is optional if other redirects are used. |
ReplaceKeyPrefixWith |
A redirect specifies the name prefix of the object key replacing KeyPrefixEquals in the redirect request.Incompatible with ReplaceKeyWith .This parameter is optional if other redirects are used. |
ReplaceKeyWith |
A redirect specifies the object key to be used in the Location header.Incompatible with ReplaceKeyPrefixWith .This parameter is optional if other redirects are used. |
HttpRedirectCode |
In the Location response header, a redirect specifies the HTTP redirect code .Possible values: any 3xx code.This parameter is optional if other redirects are used. |
Response
Headers
Responses can only contain common response headers.
Response codes
For a list of possible responses, see Responses.