Stores a new object and metadata. The uploaded object replaces any existing object with the same name. For an overview of uploading to Cloud Storage, see Uploads and downloads . For examples of performing object uploads with different Cloud Storage tools and client libraries, see the Uploading Objects guide .
This method accepts uploaded object data with the following characteristics:
- Maximum file size:5 TiB
- Accepted Media MIME types:
*/*
This method generally requires the following headers be included in a request:
Note: Metadata-only requests are notallowed. To change an object's metadata, use the patch method.
Request
HTTP request
Note: The request endpoint for this method differs from typical Cloud Storage JSON API endpoints.
POST https://storage.googleapis.com/upload/storage/v1/b/ bucket /o
In addition to standard query parameters
,
the following query parameters apply to this method. Note that for resumable uploads
, these headers can be used in the
initial POST
request but are ignored in the subsequent PUT
requests.
To see an example of how to include query parameters in a request, see the JSON API Overview page.
Parameters
bucket
string
bucket
value, if any.name
string
name
value. Overrides the object metadata's name
value, if any. For information about how to URL encode object names to be path safe, see Encoding URI path parts
.uploadType
string
-
media- Data-only upload. Upload the object data only, without any metadata. -
multipart- Multipart upload. Upload both the object data and its metadata, in a single request. -
resumable- Resumable upload. Upload the object data in a resumable fashion, using a series of at least two requests where the first request includes the metadata.
contentEncoding
string
contentEncoding
property of the final object to this value.
Setting this parameter is equivalent to setting the contentEncoding
metadata
property. This can be useful when uploading an object with uploadType=media
to indicate the encoding of the content being uploaded.ifGenerationMatch
long
ifGenerationNotMatch
long
ifMetagenerationMatch
long
ifMetagenerationNotMatch
long
kmsKeyName
string
predefinedAcl
string
Acceptable values are:
-
authenticatedRead: Object owner getsOWNERaccess, andallAuthenticatedUsersgetREADERaccess. -
bucketOwnerFullControl: Object owner getsOWNERaccess, and project team owners getOWNERaccess. -
bucketOwnerRead: Object owner getsOWNERaccess, and project team owners getREADERaccess. -
private: Object owner getsOWNERaccess. -
projectPrivate: Object owner getsOWNERaccess, and project team members get access according to their roles. -
publicRead: Object owner getsOWNERaccess, andallUsersgetREADERaccess.
iamConfiguration.uniformBucketLevelAccess.enabled
is set to true
, requests that include this parameter fail with a 400 Bad Request
response.projection
string
noAcl
, unless the object resource
specifies the acl
property, when it defaults to full
.Acceptable values are:
-
full: Include all properties. -
noAcl: Omit theowner,aclproperty.
string
AES256
. Used when encrypting
the uploaded object with a customer-supplied
encryption key
.string
string
Request body
When performing a simple upload , provide the object data in the request body. When performing a multipart upload or when initiating a resumable upload , both of which allow you to include object metadata as part of the request, supply the following properties. If you do not wish to provide object metadata in a resumable upload, the request body can be empty.
acl[]
list
iamConfiguration.uniformBucketLevelAccess.enabled
is true
for
the bucket to which you are uploading the object.cacheControl
string
"public, max-age=3600"
.contentType
string
crc32c
string
md5Hash
string
name
string
retention
object
retention.mode
string
Unlocked
or Locked
. If set to Locked
, retention.mode
cannot be
changed, the retention configuration cannot be removed, and retention.retainUntilTime
cannot be reduced.retention.retainUntilTime
datetime
1
storageClass
string
Response
If successful, this method returns an object resource in the response body.
For information about status and error codes returned by this API, see the reference page .

