Skip to main content

objects

Creates, updates, deletes, gets or lists an objects resource.

Overview

Nameobjects
TypeResource
Idgoogle.storage.objects

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
idstringThe ID of the object, including the bucket name, object name, and generation number.
namestringThe name of the object. Required if not specified by URL parameter.
aclarrayAccess controls on the object.
bucketstringThe name of the bucket containing this object.
cacheControlstringCache-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.
componentCountinteger (int32)Number of underlying components that make up this object. Components are accumulated by compose operations.
contentDispositionstringContent-Disposition of the object data.
contentEncodingstringContent-Encoding of the object data.
contentLanguagestringContent-Language of the object data.
contentTypestringContent-Type of the object data. If an object is stored without a Content-Type, it is served as application/octet-stream.
contextsobjectUser-defined or system-defined object contexts. Each object context is a key-payload pair, where the key provides the identification and the payload holds the associated value and additional metadata.
crc32cstringCRC32c 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 Data Validation and Change Detection.
customTimestring (date-time)A timestamp in RFC 3339 format specified by the user for an object.
customerEncryptionobjectMetadata of customer-supplied encryption key, if the object is encrypted by such a key.
etagstringHTTP 1.1 Entity tag for the object.
eventBasedHoldbooleanWhether an object is under event-based hold. Event-based hold is a way to retain objects until an event occurs, which is signified by the hold's release (i.e. this value is set to false). After being released (set to false), such objects will be subject to bucket-level retention (if any). One sample use case of this flag is for banks to hold loan documents for at least 3 years after loan is paid in full. Here, bucket-level retention is 3 years and the event is the loan being paid in full. In this example, these objects will be held intact for any number of years until the event has occurred (event-based hold on the object is released) and then 3 more years after that. That means retention duration of the objects begins from the moment event-based hold transitioned from true to false.
generationstring (int64)The content generation of this object. Used for object versioning.
hardDeleteTimestring (date-time)This is the time (in the future) when the soft-deleted object will no longer be restorable. It is equal to the soft delete time plus the current soft delete retention duration of the bucket.
kindstringThe kind of item this is. For objects, this is always storage#object. (default: storage#object)
kmsKeyNamestringNot currently supported. Specifying the parameter causes the request to fail with status code 400 - Bad Request.
md5HashstringMD5 hash of the data; encoded using base64. For more information about using the MD5 hash, see Data Validation and Change Detection.
mediaLinkstringMedia download link.
metadataobjectUser-provided metadata, in key/value pairs.
metagenerationstring (int64)The version of the metadata for this object at this generation. Used for preconditions and for detecting changes in metadata. A metageneration number is only meaningful in the context of a particular generation of a particular object.
ownerobjectThe owner of the object. This will always be the uploader of the object.
restoreTokenstringRestore token used to differentiate deleted objects with the same name and generation. This field is only returned for deleted objects in hierarchical namespace buckets.
retentionobjectA collection of object level retention parameters.
retentionExpirationTimestring (date-time)A server-determined value that specifies the earliest time that the object's retention period expires. This value is in RFC 3339 format. Note 1: This field is not provided for objects with an active event-based hold, since retention expiration is unknown until the hold is removed. Note 2: This value can be provided even when temporary hold is set (so that the user can reason about policy without having to first unset the temporary hold).
selfLinkstringThe link to this object.
sizestring (uint64)Content-Length of the data in bytes.
softDeleteTimestring (date-time)The time at which the object became soft-deleted in RFC 3339 format.
storageClassstringStorage class of the object.
temporaryHoldbooleanWhether an object is under temporary hold. While this flag is set to true, the object is protected against deletion and overwrites. A common use case of this flag is regulatory investigations where objects need to be retained while the investigation is ongoing. Note that unlike event-based hold, temporary hold does not impact retention expiration time of an object.
timeCreatedstring (date-time)The creation time of the object in RFC 3339 format.
timeDeletedstring (date-time)The time at which the object became noncurrent in RFC 3339 format. Will be returned if and only if this version of the object has been deleted.
timeFinalizedstring (date-time)The time when the object was finalized.
timeStorageClassUpdatedstring (date-time)The time at which the object's storage class was last changed. When the object is initially created, it will be set to timeCreated.
updatedstring (date-time)The modification time of the object metadata in RFC 3339 format. Set initially to object creation time and then updated whenever any metadata of the object changes. This includes changes made by a requester, such as modifying custom metadata, as well as changes made by Cloud Storage on behalf of a requester, such as changing the storage class based on an Object Lifecycle Configuration.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectbucket, objectgeneration, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, projection, userProject, softDeleted, restoreTokenRetrieves an object or its metadata.
listselectbucketdelimiter, endOffset, includeTrailingDelimiter, maxResults, pageToken, prefix, projection, startOffset, userProject, versions, matchGlob, filter, softDeleted, includeFoldersAsPrefixesRetrieves a list of objects matching the criteria.
insertinsertbucketcontentEncoding, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, kmsKeyName, name, predefinedAcl, projection, userProjectStores a new object and metadata.
patchupdatebucket, objectgeneration, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, overrideUnlockedRetention, predefinedAcl, projection, userProjectPatches an object's metadata.
updatereplacebucket, objectgeneration, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, overrideUnlockedRetention, predefinedAcl, projection, userProjectUpdates an object's metadata.
deletedeletebucket, objectgeneration, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, userProjectDeletes an object and its metadata. Deletions are permanent if versioning is not enabled for the bucket, or if the generation parameter is used.
composeexecdestinationBucket, destinationObjectdestinationPredefinedAcl, ifGenerationMatch, ifMetagenerationMatch, kmsKeyName, userProjectConcatenates a list of existing objects into a new object in the same bucket.
copyexecsourceBucket, sourceObject, destinationBucket, destinationObjectdestinationKmsKeyName, destinationPredefinedAcl, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, ifSourceGenerationMatch, ifSourceGenerationNotMatch, ifSourceMetagenerationMatch, ifSourceMetagenerationNotMatch, projection, sourceGeneration, userProjectCopies a source object to a destination object. Optionally overrides metadata.
rewriteexecsourceBucket, sourceObject, destinationBucket, destinationObjectdestinationKmsKeyName, destinationPredefinedAcl, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, ifSourceGenerationMatch, ifSourceGenerationNotMatch, ifSourceMetagenerationMatch, ifSourceMetagenerationNotMatch, maxBytesRewrittenPerCall, projection, rewriteToken, sourceGeneration, userProjectRewrites a source object to a destination object. Optionally overrides metadata.
moveexecbucket, sourceObject, destinationObjectifSourceGenerationMatch, ifSourceGenerationNotMatch, ifSourceMetagenerationMatch, ifSourceMetagenerationNotMatch, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, projection, userProjectMoves the source object to the destination object in the same bucket.
watch_allexecbucketdelimiter, endOffset, includeTrailingDelimiter, maxResults, pageToken, prefix, projection, startOffset, userProject, versionsWatch for changes on all objects in a bucket.
restoreexecbucket, object, generationifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, copySourceAcl, projection, userProject, restoreTokenRestores a soft-deleted object.
bulk_restoreexecbucketInitiates a long-running bulk restore operation on the specified bucket.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
bucketstring
destinationBucketstring
destinationObjectstring
generationstring (int64)
objectstring
sourceBucketstring
sourceObjectstring
contentEncodingstring
copySourceAclboolean
delimiterstring
destinationKmsKeyNamestring
destinationPredefinedAclstring
endOffsetstring
filterstring
generationstring (int64)
ifGenerationMatchstring (int64)
ifGenerationNotMatchstring (int64)
ifMetagenerationMatchstring (int64)
ifMetagenerationNotMatchstring (int64)
ifSourceGenerationMatchstring (int64)
ifSourceGenerationNotMatchstring (int64)
ifSourceMetagenerationMatchstring (int64)
ifSourceMetagenerationNotMatchstring (int64)
includeFoldersAsPrefixesboolean
includeTrailingDelimiterboolean
kmsKeyNamestring
matchGlobstring
maxBytesRewrittenPerCallstring (int64)
maxResultsinteger (uint32)
namestring
overrideUnlockedRetentionboolean
pageTokenstring
predefinedAclstring
prefixstring
projectionstring
restoreTokenstring
rewriteTokenstring
softDeletedboolean
sourceGenerationstring (int64)
startOffsetstring
userProjectstring
versionsboolean

SELECT examples

Retrieves an object or its metadata.

SELECT
id,
name,
acl,
bucket,
cacheControl,
componentCount,
contentDisposition,
contentEncoding,
contentLanguage,
contentType,
contexts,
crc32c,
customTime,
customerEncryption,
etag,
eventBasedHold,
generation,
hardDeleteTime,
kind,
kmsKeyName,
md5Hash,
mediaLink,
metadata,
metageneration,
owner,
restoreToken,
retention,
retentionExpirationTime,
selfLink,
size,
softDeleteTime,
storageClass,
temporaryHold,
timeCreated,
timeDeleted,
timeFinalized,
timeStorageClassUpdated,
updated
FROM google.storage.objects
WHERE bucket = '{{ bucket }}' -- required
AND object = '{{ object }}' -- required
AND generation = '{{ generation }}'
AND ifGenerationMatch = '{{ ifGenerationMatch }}'
AND ifGenerationNotMatch = '{{ ifGenerationNotMatch }}'
AND ifMetagenerationMatch = '{{ ifMetagenerationMatch }}'
AND ifMetagenerationNotMatch = '{{ ifMetagenerationNotMatch }}'
AND projection = '{{ projection }}'
AND userProject = '{{ userProject }}'
AND softDeleted = '{{ softDeleted }}'
AND restoreToken = '{{ restoreToken }}';

INSERT examples

Stores a new object and metadata.

INSERT INTO google.storage.objects (
data__acl,
data__bucket,
data__cacheControl,
data__componentCount,
data__contentDisposition,
data__contentEncoding,
data__contentLanguage,
data__contentType,
data__crc32c,
data__customTime,
data__customerEncryption,
data__etag,
data__eventBasedHold,
data__generation,
data__id,
data__kind,
data__kmsKeyName,
data__md5Hash,
data__mediaLink,
data__metadata,
data__contexts,
data__restoreToken,
data__metageneration,
data__name,
data__owner,
data__retentionExpirationTime,
data__retention,
data__selfLink,
data__size,
data__storageClass,
data__temporaryHold,
data__timeCreated,
data__timeDeleted,
data__timeFinalized,
data__softDeleteTime,
data__hardDeleteTime,
data__timeStorageClassUpdated,
data__updated,
bucket,
contentEncoding,
ifGenerationMatch,
ifGenerationNotMatch,
ifMetagenerationMatch,
ifMetagenerationNotMatch,
kmsKeyName,
name,
predefinedAcl,
projection,
userProject
)
SELECT
'{{ acl }}',
'{{ bucket }}',
'{{ cacheControl }}',
{{ componentCount }},
'{{ contentDisposition }}',
'{{ contentEncoding }}',
'{{ contentLanguage }}',
'{{ contentType }}',
'{{ crc32c }}',
'{{ customTime }}',
'{{ customerEncryption }}',
'{{ etag }}',
{{ eventBasedHold }},
'{{ generation }}',
'{{ id }}',
'{{ kind }}',
'{{ kmsKeyName }}',
'{{ md5Hash }}',
'{{ mediaLink }}',
'{{ metadata }}',
'{{ contexts }}',
'{{ restoreToken }}',
'{{ metageneration }}',
'{{ name }}',
'{{ owner }}',
'{{ retentionExpirationTime }}',
'{{ retention }}',
'{{ selfLink }}',
'{{ size }}',
'{{ storageClass }}',
{{ temporaryHold }},
'{{ timeCreated }}',
'{{ timeDeleted }}',
'{{ timeFinalized }}',
'{{ softDeleteTime }}',
'{{ hardDeleteTime }}',
'{{ timeStorageClassUpdated }}',
'{{ updated }}',
'{{ bucket }}',
'{{ contentEncoding }}',
'{{ ifGenerationMatch }}',
'{{ ifGenerationNotMatch }}',
'{{ ifMetagenerationMatch }}',
'{{ ifMetagenerationNotMatch }}',
'{{ kmsKeyName }}',
'{{ name }}',
'{{ predefinedAcl }}',
'{{ projection }}',
'{{ userProject }}'
RETURNING
id,
name,
acl,
bucket,
cacheControl,
componentCount,
contentDisposition,
contentEncoding,
contentLanguage,
contentType,
contexts,
crc32c,
customTime,
customerEncryption,
etag,
eventBasedHold,
generation,
hardDeleteTime,
kind,
kmsKeyName,
md5Hash,
mediaLink,
metadata,
metageneration,
owner,
restoreToken,
retention,
retentionExpirationTime,
selfLink,
size,
softDeleteTime,
storageClass,
temporaryHold,
timeCreated,
timeDeleted,
timeFinalized,
timeStorageClassUpdated,
updated
;

UPDATE examples

Patches an object's metadata.

UPDATE google.storage.objects
SET
data__acl = '{{ acl }}',
data__bucket = '{{ bucket }}',
data__cacheControl = '{{ cacheControl }}',
data__componentCount = {{ componentCount }},
data__contentDisposition = '{{ contentDisposition }}',
data__contentEncoding = '{{ contentEncoding }}',
data__contentLanguage = '{{ contentLanguage }}',
data__contentType = '{{ contentType }}',
data__crc32c = '{{ crc32c }}',
data__customTime = '{{ customTime }}',
data__customerEncryption = '{{ customerEncryption }}',
data__etag = '{{ etag }}',
data__eventBasedHold = {{ eventBasedHold }},
data__generation = '{{ generation }}',
data__id = '{{ id }}',
data__kind = '{{ kind }}',
data__kmsKeyName = '{{ kmsKeyName }}',
data__md5Hash = '{{ md5Hash }}',
data__mediaLink = '{{ mediaLink }}',
data__metadata = '{{ metadata }}',
data__contexts = '{{ contexts }}',
data__restoreToken = '{{ restoreToken }}',
data__metageneration = '{{ metageneration }}',
data__name = '{{ name }}',
data__owner = '{{ owner }}',
data__retentionExpirationTime = '{{ retentionExpirationTime }}',
data__retention = '{{ retention }}',
data__selfLink = '{{ selfLink }}',
data__size = '{{ size }}',
data__storageClass = '{{ storageClass }}',
data__temporaryHold = {{ temporaryHold }},
data__timeCreated = '{{ timeCreated }}',
data__timeDeleted = '{{ timeDeleted }}',
data__timeFinalized = '{{ timeFinalized }}',
data__softDeleteTime = '{{ softDeleteTime }}',
data__hardDeleteTime = '{{ hardDeleteTime }}',
data__timeStorageClassUpdated = '{{ timeStorageClassUpdated }}',
data__updated = '{{ updated }}'
WHERE
bucket = '{{ bucket }}' --required
AND object = '{{ object }}' --required
AND generation = '{{ generation}}'
AND ifGenerationMatch = '{{ ifGenerationMatch}}'
AND ifGenerationNotMatch = '{{ ifGenerationNotMatch}}'
AND ifMetagenerationMatch = '{{ ifMetagenerationMatch}}'
AND ifMetagenerationNotMatch = '{{ ifMetagenerationNotMatch}}'
AND overrideUnlockedRetention = {{ overrideUnlockedRetention}}
AND predefinedAcl = '{{ predefinedAcl}}'
AND projection = '{{ projection}}'
AND userProject = '{{ userProject}}'
RETURNING
id,
name,
acl,
bucket,
cacheControl,
componentCount,
contentDisposition,
contentEncoding,
contentLanguage,
contentType,
contexts,
crc32c,
customTime,
customerEncryption,
etag,
eventBasedHold,
generation,
hardDeleteTime,
kind,
kmsKeyName,
md5Hash,
mediaLink,
metadata,
metageneration,
owner,
restoreToken,
retention,
retentionExpirationTime,
selfLink,
size,
softDeleteTime,
storageClass,
temporaryHold,
timeCreated,
timeDeleted,
timeFinalized,
timeStorageClassUpdated,
updated;

REPLACE examples

Updates an object's metadata.

REPLACE google.storage.objects
SET
data__acl = '{{ acl }}',
data__bucket = '{{ bucket }}',
data__cacheControl = '{{ cacheControl }}',
data__componentCount = {{ componentCount }},
data__contentDisposition = '{{ contentDisposition }}',
data__contentEncoding = '{{ contentEncoding }}',
data__contentLanguage = '{{ contentLanguage }}',
data__contentType = '{{ contentType }}',
data__crc32c = '{{ crc32c }}',
data__customTime = '{{ customTime }}',
data__customerEncryption = '{{ customerEncryption }}',
data__etag = '{{ etag }}',
data__eventBasedHold = {{ eventBasedHold }},
data__generation = '{{ generation }}',
data__id = '{{ id }}',
data__kind = '{{ kind }}',
data__kmsKeyName = '{{ kmsKeyName }}',
data__md5Hash = '{{ md5Hash }}',
data__mediaLink = '{{ mediaLink }}',
data__metadata = '{{ metadata }}',
data__contexts = '{{ contexts }}',
data__restoreToken = '{{ restoreToken }}',
data__metageneration = '{{ metageneration }}',
data__name = '{{ name }}',
data__owner = '{{ owner }}',
data__retentionExpirationTime = '{{ retentionExpirationTime }}',
data__retention = '{{ retention }}',
data__selfLink = '{{ selfLink }}',
data__size = '{{ size }}',
data__storageClass = '{{ storageClass }}',
data__temporaryHold = {{ temporaryHold }},
data__timeCreated = '{{ timeCreated }}',
data__timeDeleted = '{{ timeDeleted }}',
data__timeFinalized = '{{ timeFinalized }}',
data__softDeleteTime = '{{ softDeleteTime }}',
data__hardDeleteTime = '{{ hardDeleteTime }}',
data__timeStorageClassUpdated = '{{ timeStorageClassUpdated }}',
data__updated = '{{ updated }}'
WHERE
bucket = '{{ bucket }}' --required
AND object = '{{ object }}' --required
AND generation = '{{ generation}}'
AND ifGenerationMatch = '{{ ifGenerationMatch}}'
AND ifGenerationNotMatch = '{{ ifGenerationNotMatch}}'
AND ifMetagenerationMatch = '{{ ifMetagenerationMatch}}'
AND ifMetagenerationNotMatch = '{{ ifMetagenerationNotMatch}}'
AND overrideUnlockedRetention = {{ overrideUnlockedRetention}}
AND predefinedAcl = '{{ predefinedAcl}}'
AND projection = '{{ projection}}'
AND userProject = '{{ userProject}}'
RETURNING
id,
name,
acl,
bucket,
cacheControl,
componentCount,
contentDisposition,
contentEncoding,
contentLanguage,
contentType,
contexts,
crc32c,
customTime,
customerEncryption,
etag,
eventBasedHold,
generation,
hardDeleteTime,
kind,
kmsKeyName,
md5Hash,
mediaLink,
metadata,
metageneration,
owner,
restoreToken,
retention,
retentionExpirationTime,
selfLink,
size,
softDeleteTime,
storageClass,
temporaryHold,
timeCreated,
timeDeleted,
timeFinalized,
timeStorageClassUpdated,
updated;

DELETE examples

Deletes an object and its metadata. Deletions are permanent if versioning is not enabled for the bucket, or if the generation parameter is used.

DELETE FROM google.storage.objects
WHERE bucket = '{{ bucket }}' --required
AND object = '{{ object }}' --required
AND generation = '{{ generation }}'
AND ifGenerationMatch = '{{ ifGenerationMatch }}'
AND ifGenerationNotMatch = '{{ ifGenerationNotMatch }}'
AND ifMetagenerationMatch = '{{ ifMetagenerationMatch }}'
AND ifMetagenerationNotMatch = '{{ ifMetagenerationNotMatch }}'
AND userProject = '{{ userProject }}';

Lifecycle Methods

Concatenates a list of existing objects into a new object in the same bucket.

EXEC google.storage.objects.compose 
@destinationBucket='{{ destinationBucket }}' --required,
@destinationObject='{{ destinationObject }}' --required,
@destinationPredefinedAcl='{{ destinationPredefinedAcl }}',
@ifGenerationMatch='{{ ifGenerationMatch }}',
@ifMetagenerationMatch='{{ ifMetagenerationMatch }}',
@kmsKeyName='{{ kmsKeyName }}',
@userProject='{{ userProject }}'
@@json=
'{
"destination": "{{ destination }}",
"kind": "{{ kind }}",
"sourceObjects": "{{ sourceObjects }}"
}';