Google Cloud Storage supports several standard HTTP request methods. Each method can use numerous request headers and response headers. The following document describes all of the supported HTTP methods as well as the most frequently used headers that are used with each method. The documentation does not describe all of the possible request headers you could use, rather, it describes only those headers that you are likely to use or see in a request and response.
Service Requests
Bucket Requests
Object Requests
If you do not provide authorization information when required to perform a request, the Google Cloud Storage issues a 401 unauthorized error. For more information, see Status Codes .
Conventions used in this document:
-
The
Authorization
header is represented as<authentication string>
. If you are using the XML API in a simple migration scenario, for example, to work interoperably with another storage provider, then theAuthorization
has the format discussed in Authentication in a Simple Migration Scenario . Otherwise, theAuthorization
header has the format discussed in OAuth 2.0 Authentication . -
The
Host
header used in this document is of the form:Host: BUCKET-NAME.storage.googleapis.com
where the bucket name is specified as part of the hostname. In all operations except GET service, you can also specify the bucket as part of the URL path. For more information, see Request URIs .
GET Service
Lists all of the buckets in a specified project.
Request Details
Query String Parameters
This request does not use query string parameters.
Request Headers
Header | Description | Required |
---|---|---|
Authorization
|
The authentication string for the request. | Yes |
Content-Length
|
The length of the request body without headers (in bytes). | Yes |
Date
|
The date and time of the request. | Yes |
Host
|
The URI for Google Cloud Storage. | Yes |
x-goog-project-id
|
The project ID of a project. | Yes |
Request Body Elements
This request does not include an XML document in the request body.
Request Syntax
GET / HTTP/1.1 Host: storage.googleapis.com Date: <date> Authorization: <authentication string> Content-Length: <request body length> x-goog-project-id: <project id>
Response Details
Response Headers
The request can return a variety of response headers depending on the request headers you use.
Response Body Elements
Element | Description |
---|---|
ListAllMyBucketsResult | Container for bucket information. |
Owner | Container for bucket owner information. |
ID | Google Cloud Storage ID of the bucket owner. |
DisplayName | Not currently implemented. The value is always an empty string. |
Buckets | Container for information about the owner's buckets. |
Bucket | Container for information about a specific bucket. |
Name | Name of the bucket. |
CreationDate | Creation date for the bucket. |
Status Code Details
If the GET Service request fails, it returns a 403 Forbidden status code. The body of the error response will also contain a message describing the reason why the request failed.
Sample Request and Response
The following sample lists the buckets in the specified project.
Sample Request
GET / HTTP/1.1 Host: storage.googleapis.com Date: Mon, 15 Feb 2010 11:00:00 GMT Content-Length: 0 x-goog-project-id: 123456789123 Authorization: <authentication string>
Sample Response
HTTP/1.1 200 OK Content-Length: 648 Content-Type: application/xml Date: Mon, 15 Feb 2010 11:00:01 GMT <?xml version='1.0' encoding='utf-8'?> <ListAllMyBucketsResult xmlns='http://doc.s3.amazonaws.com/2006-03-01'> <Owner> <ID>84fac329bceSAMPLE777d5d22b8SAMPLE77d85ac2SAMPLE2dfcf7c4adf34da46</ID> <DisplayName></DisplayName> </Owner> <Buckets> <Bucket> <Name>city-maps</Name> <CreationDate>2009-12-16T18:36:25.369Z</CreationDate> </Bucket> <Bucket> <Name>state-maps</Name> <CreationDate>2009-12-16T18:42:37.408Z</CreationDate> </Bucket> <Bucket> <Name>country-maps</Name> <CreationDate>2010-01-22T01:27:03.633Z</CreationDate> </Bucket> </Buckets> </ListAllMyBucketsResult>
Comments
The GET Service method is a simple GET request without a bucket or object scope. The request returns the list of buckets in an XML document in the response body. The request must be authenticated (anonymous requests will fail). By default, only the project owners group can list buckets because they are the owner of all buckets within the project. The project team and project editors groups have only view or write access to buckets, respectively.
DELETE Bucket
Deletes an empty bucket.
Request Details
Query String Parameters
This request does not use query string parameters.
Request Headers
Header | Description | Required |
---|---|---|
Authorization
|
The authentication string for the request. | Yes |
Content-Length
|
The length of the request body without headers (in bytes). | Yes |
Date
|
The date and time of the request. | Yes |
Host
|
The URI for Google Cloud Storage. | Yes |
Request Body Elements
This request does not include an XML document in the request body.
Request Syntax
DELETE / HTTP/1.1 Host: bucket.storage.googleapis.com Date: <date> Authorization: <authentication string> Content-Length: <request body length>
Response Details
Response Headers
The request can return a variety of response headers depending on the request headers you use.
Response Body Elements
The response does not include an XML document in the response body.
Status Code Details
If there are objects in the bucket when you attempt to delete it you will get a
409 Conflict
status code and the body of the error response will contain
BucketNotEmpty
in the
Code
element.
If the bucket does not exist you will get a
404 Not Found
status code and the body of the error response will contain
NoSuchBucket
in the
Code
element.
Sample Request and Response
The following sample deletes a bucket named travel-maps.
Sample Request
DELETE / HTTP/1.1 Host: travel-maps.storage.googleapis.com Date: Mon, 15 Feb 2010 11:00:00 GMT Content-Length: 0 Authorization: <authentication string>
Sample Response
HTTP/1.1 204 No Content Date: Mon, 15 Feb 2010 11:00:01 GMT Expires: Mon, 15 Feb 2010 11:00:01 GMT
Comments
The DELETE Bucket method is a simple DELETE request with bucket scope. You must be a member of the project owners group to delete buckets. Also, all DELETE Bucket requests must be authenticated.
As a best practice, after you delete all of the objects from a bucket you should set the bucket ACLs so that no users can create objects in the bucket.
GET Bucket
Lists the objects that are in a bucket, as well as a bucket's configuration including ACL , CORS , Lifecycle , Logging , and Object Versioning .
Request Details
Query String Parameters
Parameter | Description | Required |
---|---|---|
acl
|
You can use this to display the ACLs of an existing bucket. | No |
cors
|
You can use this to display the CORS configuration of an existing bucket. | No |
delimiter
|
A character or multiple characters that can be used to simplify a list of objects that use a directory-like naming scheme. Can be used in conjunction with a
prefix
.
|
No |
generation-marker
|
The object generation after which you want to start listing objects. If you use generation-marker, you must also use marker. | No |
lifecycle
|
You can use this to display the lifecycle configuration of an existing bucket. | No |
location
|
You can use this to display the location of the bucket. For a list of locations, see Specifying Bucket Location . | No |
logging
|
You can use this only to display the logging configuration of an existing bucket. | No |
marker
|
The object name after which you want to start listing objects. | No |
max-keys
|
The maximum number of objects to return in a list object request. | No |
prefix
|
A string that can be used to limit the number of objects that are returned in a GET Bucket request. Can be used in conjunction with a
delimiter
.
|
No |
storageClass
|
You can use this to display the storage class of the bucket, STANDARD or DURABLE_REDUCED_AVAILABILITY. | No |
versioning
|
You can use this to display the versioning configuration of an existing bucket. | No |
versions
|
If specified on a versioned bucket, returns the list of all object versions. If omitted, only lists current versions. | No |
Request Headers
Header | Description | Required |
---|---|---|
Authorization
|
The authentication string for the request. | Yes |
Content-Length
|
The length of the request body without headers (in bytes). | Yes |
Date
|
The date and time of the request. | Yes |
Host
|
The URI for Google Cloud Storage. | Yes |
Request Body Elements
This request does not include an XML document in the request body.
Request Syntax
The following syntax applies to GET Bucket requests that use the
acl
query string parameter.
GET /?acl HTTP/1.1 Host: bucket.storage.googleapis.com Date: <date> Content-Length: <request body length> Authorization: <authentication string>
The following syntax applies to GET Bucket requests that use the
cors
query string parameter.
GET /?cors HTTP/1.1 Host: bucket.storage.googleapis.com Date: <date> Content-Length: <request body length> Authorization: <authentication string>
The following syntax applies to GET Bucket requests that use the
lifecycle
query string parameter.
GET /?lifecycle HTTP/1.1 Host: bucket.storage.googleapis.com Date: <date> Content-Length: <request body length> Authorization: <authentication string>
The following syntax applies to GET Bucket requests that use the
location
query string parameter.
GET /?location HTTP/1.1 Host: bucket.storage.googleapis.com Date: <date> Content-Length: <request body length> Authorization: <authentication string>
The following syntax applies to GET Bucket requests that use the
logging
query string parameter.
GET /?logging HTTP/1.1 Host: bucket.storage.googleapis.com Date: <date> Content-Length: <request body length> Authorization: <authentication string>
The following syntax applies to GET Bucket requests that use the
storageClass
query string parameter.
GET /?storageClass HTTP/1.1 Host: bucket.storage.googleapis.com Date: <date> Content-Length: <request body length> Authorization: <authentication string>
The following syntax applies to GET Bucket requests that use the
versioning
query string parameter.
GET /?versioning HTTP/1.1 Host: bucket.storage.googleapis.com Date: <date> Content-Length: <request body length> Authorization: <authentication string>
The following syntax applies to GET Bucket requests that use either no parameters, or one or more of the
delimiter
,
generation-marker
,
marker
,
max-keys
,
prefix
, and
versions
query string parameters.
GET /?prefix=a_prefix&marker=a_marker&max-keys=max_number_of_keys&delimiter=a_delimiter HTTP/1.1 Host: bucket.storage.googleapis.com Date: <date> Content-Length: <request body length> Authorization: <authentication string>
Response Details
Response Headers
The request can return a variety of response headers depending on the request headers you use.
Response Body Elements
The following response body elements are applicable only if you use either no parameters, or one or more of the
delimiter
,
generation-marker
,
marker
,
max-keys
,
prefix
, or
versions
query string parameters to list objects in a bucket.
Element | Description |
---|---|
ListBucketResult
|
Container for the object information you are requesting. |
Name
|
The bucket name. |
CommonPrefixes
|
Container for prefixes that satisfy your
prefix
and
delimiter
constraints. This container is used only if you specify a
delimiter
and a
prefix
in the request.
|
Delimiter
|
The
delimiter
that you specified in the request.
|
MaxKeys
|
The
max-keys
that you specified in the request.
|
Prefix
|
The
prefix
that you specified in the request.
|
GenerationMarker
|
The
generation-marker
that you specified in the request.
|
NextGenerationMarker
|
If the list of returned objects is incomplete and
versions
parameter was used,
NextGenerationMarker
provides the generation of the last object that was returned. If the list is already complete,
NextGenerationMarker
is not returned.
|
Marker
|
The
marker
that you specified in the request.
|
NextMarker
|
NextMarker
provides the name of the last object that was returned. The value of
NextMarker
can be provided in the
marker
query string parameter in a future GET Bucket call to continue listing the Bucket after this set of results. If there are no more objects in the Bucket that follow the last object in the list,
NextMarker
is not returned.
|
IsTruncated
|
Indicates whether or not all of the objects in a bucket appear on the list. If
max-keys
is less than the number of objects in a bucket, this element is True.
|
Contents
|
Container for object information if
versions
query parameter is not used.
|
Version
|
Container for object information if
versions
query parameter is used.
|
Key
|
The name of an object. |
Generation
|
The generation of the object. |
MetaGeneration
|
Generation of the metadata of the object. |
IsLatest
|
If
versions
query parameter specified, this is set to true if the object is currently live. Live meaning that if this object is requested without generation, this object is returned.
|
LastModified
|
The date and time that an object was last modified. |
DeletedTime
|
If
versions
query parameter was specified, contains the date and time that an object was overwritten or deleted for non-current objects.
|
ETag
|
An HTTP 1.1 entity tag for the object. |
Size
|
Size of the object in bytes. |
StorageClass
|
STANDARD or DURABLE_REDUCED_AVAILABILITY. |
Owner
|
Container for object owner information. |
ID
|
A Google Storage ID. |
DisplayName
|
Not currently implemented. |
The following response body elements are applicable only if you use the
acl
query string parameter to list a bucket's ACLs.
Element | Description |
---|---|
Owner
|
Container for bucket owner information. |
ID
|
The Google Storage ID of the bucket owner or the Google Storage ID of the user or group for whom the ACLs apply. |
Name
|
Comment field for
GroupByEmail
,
GroupById
,
UserByEmail
, and
UserById
.
|
AccessControlList
|
Container for the ACLs you are retrieving. |
Entries
|
Container for the ACL entries you are retrieving. |
Entry
|
The ACL entry you are retrieving. |
Scope
|
The scope to which the ACLs apply. |
Permission
|
The permission that has been granted. Can be any of the Google Cloud Storage permissions, including
READ
,
WRITE
, or
FULL_CONTROL
|
EmailAddress
|
A Google account email address or a Google group email address. |
Domain
|
A Google Apps domain. |
The following response body elements are applicable only if you use the
cors
query string parameter to get the bucket's CORS configuration.
Element | Description |
---|---|
CorsConfig
|
Container for one or more Cors configuration containers. If you specify multiple Cors configurations, be aware that the Cors configurations will be evaluated in the order listed within the CorsConfig container, with the first Cors configuration matching the Origin and Method of the request used to determine any CORS response headers to add to the response. |
Cors
|
Container for a CORS configuration to be applied to the bucket.You can specify multiple Origins and multiple Methods in each Cors container. There will be a match if the request Origin matches any of the Origins in the Cors container and the request Method matches any of the Methods in the Cors container. |