Stores a new object and metadata. For tips on uploading to Google Cloud Storage, see best practices.
This method supports an /upload URI and accepts uploaded media with the following characteristics:
- Maximum file size: 5 TB
- Accepted Media MIME types:
*/*
The authenticated user must have WRITER
permissions on the bucket.
Note: Metadata-only requests are not allowed. To change an object's metadata, use either the update or patch methods.
To provide a customer-supplied encryption key along with the object upload, use the headers listed on the Encryption page in your request.
Request
HTTP request
This method provides media upload functionality through the following URI. For more details, see the documents on object uploads.
- Upload URI, for media upload requests:
POST https://www.googleapis.com/upload/storage/v1/b/bucket/o
Parameters
Parameter name | Value | Description |
---|---|---|
Path parameters | ||
bucket |
string |
Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.
|
Required query parameters | ||
uploadType |
string |
The type of upload request to the /upload URI.
Acceptable values are:
|
Optional query parameters | ||
contentEncoding |
string |
If set, sets the 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 |
Makes the operation conditional on whether the object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object. |
ifGenerationNotMatch |
long |
Makes the operation conditional on whether the object's current generation does not match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object. |
ifMetagenerationMatch |
long |
Makes the operation conditional on whether the object's current metageneration matches the given value. |
ifMetagenerationNotMatch |
long |
Makes the operation conditional on whether the object's current metageneration does not match the given value. |
kmsKeyName |
string |
Resource name of the Cloud KMS key that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.
|
name |
string |
Name of the object. Required when the object metadata is not otherwise provided. 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.
|
predefinedAcl |
string |
Apply a predefined set of access controls to this object.
Acceptable values are:
|
projection |
string |
Set of properties to return. Defaults to noAcl , unless the object resource specifies the acl property, when it defaults to full .
Acceptable values are:
|
userProject |
string |
The project to be billed for this request. Required for Requester Pays buckets. |
Request body
In the request body, supply an object resource with the following properties as the metadata. For more information, see the documents on object uploads.
Property name | Value | Description | Notes |
---|---|---|---|
Optional Properties | |||
acl[] |
list |
Access controls on the object, containing one or more objectAccessControls Resources. | writable |
cacheControl |
string |
Cache-Control directive for the object data. If omitted, and the object is accessible to all anonymous users, the default will be public, max-age=3600 . |
writable |
contentDisposition |
string |
Content-Disposition of the object data. | writable |
contentEncoding |
string |
Content-Encoding of the object data. | writable |
contentLanguage |
string |
Content-Language of the object data. | writable |
contentType |
string |
Content-Type of the object data. If an object is stored without a Content-Type, it is served as application/octet-stream. | writable |
crc32c |
string |
CRC32c checksum, as described in RFC 4960, Appendix B; encoded using base64 in big-endian byte order. For more information about using the CRC32c checksum, see Hashes and ETags: Best Practices. | writable |
eventBasedHold |
boolean |
Whether or not the object is subject to an event-based hold. | writable |
md5Hash |
string |
MD5 hash of the data; encoded using base64. For more information about using the MD5 hash, see Hashes and ETags: Best Practices. | writable |
metadata |
object |
User-provided metadata, in key/value pairs. | writable |
metadata.(key) |
string |
An individual metadata entry. | writable |
name |
string |
The name of the object. Required if not specified by URL parameter. | writable |
storageClass |
string |
Storage class of the object. | writable |
temporaryHold |
boolean |
Whether or not the object is subject to a temporary hold. | writable |
Response
If successful, this method returns an object resource in the response body.