Skip to main content

objects_content

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

Overview​

Nameobjects_content
TypeResource
Idgoogle.storage.objects_content

Fields​

The following fields are returned by SELECT queries:

The raw content of the object.

NameDatatypeDescription
contentsstringThe text content of the object.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
downloadselectbucket, objectgeneration, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, projection, restoreToken, softDeleted, userProjectDownloads the content of an object as text and returns it in the contents field. Text (non-binary) objects only: content is read as a string, so binary object content is unsupported and may be mangled (base64 encoding is not supported). Object names containing slashes must be URL-encoded in the object parameter (for example env%2Fterraform.tfstate), as with the objects get method.
uploadinsertbucket, name, data__contentscontentEncoding, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, kmsKeyName, predefinedAcl, projection, userProjectUploads object content provided as a text string in the contents field, creating the object or overwriting the content of an existing object (use ifGenerationMatch = 0 for a create-only conditional write). Text (non-binary) content only: binary content is unsupported and may be mangled (base64 encoding is not supported). When the content is itself valid JSON (for example a terraform.tfstate file), wrap the value in the string() function - for example data__contents = string('{...}') - to store it byte-for-byte; without string() the stackql parser interprets valid JSON values as objects and the content is stored as normalized (compact) JSON.
uploadreplacebucket, name, data__contentscontentEncoding, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, kmsKeyName, predefinedAcl, projection, userProjectUploads object content provided as a text string in the contents field, creating the object or overwriting the content of an existing object (use ifGenerationMatch = 0 for a create-only conditional write). Text (non-binary) content only: binary content is unsupported and may be mangled (base64 encoding is not supported). When the content is itself valid JSON (for example a terraform.tfstate file), wrap the value in the string() function - for example data__contents = string('{...}') - to store it byte-for-byte; without string() the stackql parser interprets valid JSON values as objects and the content is stored as normalized (compact) JSON.

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
namestring
objectstring
contentEncodingstring
generationstring (int64)
ifGenerationMatchstring (int64)
ifGenerationNotMatchstring (int64)
ifMetagenerationMatchstring (int64)
ifMetagenerationNotMatchstring (int64)
kmsKeyNamestring
predefinedAclstring
projectionstring
restoreTokenstring
softDeletedboolean
userProjectstring

SELECT examples​

Downloads the content of an object as text and returns it in the contents field. Text (non-binary) objects only: content is read as a string, so binary object content is unsupported and may be mangled (base64 encoding is not supported). Object names containing slashes must be URL-encoded in the object parameter (for example env%2Fterraform.tfstate), as with the objects get method.

SELECT
contents
FROM google.storage.objects_content
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 restoreToken = '{{ restoreToken }}'
AND softDeleted = '{{ softDeleted }}'
AND userProject = '{{ userProject }}'
;

INSERT examples​

Uploads object content provided as a text string in the contents field, creating the object or overwriting the content of an existing object (use ifGenerationMatch = 0 for a create-only conditional write). Text (non-binary) content only: binary content is unsupported and may be mangled (base64 encoding is not supported). When the content is itself valid JSON (for example a terraform.tfstate file), wrap the value in the string() function - for example data__contents = string('{...}') - to store it byte-for-byte; without string() the stackql parser interprets valid JSON values as objects and the content is stored as normalized (compact) JSON.

INSERT INTO google.storage.objects_content (
data__contents,
bucket,
name,
contentEncoding,
ifGenerationMatch,
ifGenerationNotMatch,
ifMetagenerationMatch,
ifMetagenerationNotMatch,
kmsKeyName,
predefinedAcl,
projection,
userProject
)
SELECT
'{{ contents }}' /* required */,
'{{ bucket }}',
'{{ name }}',
'{{ contentEncoding }}',
'{{ ifGenerationMatch }}',
'{{ ifGenerationNotMatch }}',
'{{ ifMetagenerationMatch }}',
'{{ ifMetagenerationNotMatch }}',
'{{ kmsKeyName }}',
'{{ 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
;

REPLACE examples​

Uploads object content provided as a text string in the contents field, creating the object or overwriting the content of an existing object (use ifGenerationMatch = 0 for a create-only conditional write). Text (non-binary) content only: binary content is unsupported and may be mangled (base64 encoding is not supported). When the content is itself valid JSON (for example a terraform.tfstate file), wrap the value in the string() function - for example data__contents = string('{...}') - to store it byte-for-byte; without string() the stackql parser interprets valid JSON values as objects and the content is stored as normalized (compact) JSON.

REPLACE google.storage.objects_content
SET
data__contents = '{{ contents }}'
WHERE
bucket = '{{ bucket }}' --required
AND name = '{{ name }}' --required
AND data__contents = '{{ contents }}' --required
AND contentEncoding = '{{ contentEncoding}}'
AND ifGenerationMatch = '{{ ifGenerationMatch}}'
AND ifGenerationNotMatch = '{{ ifGenerationNotMatch}}'
AND ifMetagenerationMatch = '{{ ifMetagenerationMatch}}'
AND ifMetagenerationNotMatch = '{{ ifMetagenerationNotMatch}}'
AND kmsKeyName = '{{ kmsKeyName}}'
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;