objects_content
Creates, updates, deletes, gets or lists an objects_content resource.
Overview
| Name | objects_content |
| Type | Resource |
| Id | google.storage.objects_content |
Fields
The following fields are returned by SELECT queries:
- download
The raw content of the object.
| Name | Datatype | Description |
|---|---|---|
contents | string | The text content of the object. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
download | select | bucket, object | generation, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, projection, restoreToken, softDeleted, userProject | 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. |
upload | insert | bucket, name, data__contents | contentEncoding, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, kmsKeyName, predefinedAcl, projection, userProject | 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. |
upload | replace | bucket, name, data__contents | contentEncoding, ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch, kmsKeyName, predefinedAcl, projection, userProject | 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. |
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.
| Name | Datatype | Description |
|---|---|---|
bucket | string | |
name | string | |
object | string | |
contentEncoding | string | |
generation | string (int64) | |
ifGenerationMatch | string (int64) | |
ifGenerationNotMatch | string (int64) | |
ifMetagenerationMatch | string (int64) | |
ifMetagenerationNotMatch | string (int64) | |
kmsKeyName | string | |
predefinedAcl | string | |
projection | string | |
restoreToken | string | |
softDeleted | boolean | |
userProject | string |
SELECT examples
- download
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
- upload
- Manifest
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
;
# Description fields are for documentation purposes
- name: objects_content
props:
- name: bucket
value: "{{ bucket }}"
description: Required parameter for the objects_content resource.
- name: name
value: "{{ name }}"
description: Required parameter for the objects_content resource.
- name: contents
value: "{{ contents }}"
description: |
The text content of the object. Text (non-binary) content only.
- name: contentEncoding
value: "{{ contentEncoding }}"
- name: ifGenerationMatch
value: "{{ ifGenerationMatch }}"
- name: ifGenerationNotMatch
value: "{{ ifGenerationNotMatch }}"
- name: ifMetagenerationMatch
value: "{{ ifMetagenerationMatch }}"
- name: ifMetagenerationNotMatch
value: "{{ ifMetagenerationNotMatch }}"
- name: kmsKeyName
value: "{{ kmsKeyName }}"
- name: predefinedAcl
value: "{{ predefinedAcl }}"
- name: projection
value: "{{ projection }}"
- name: userProject
value: "{{ userProject }}"
REPLACE examples
- upload
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;