File
class resources.file.File
Base class: Resource
A file which is stored in Cloudomation.
To store data in a file there are three additional arguments for the save()
method available:
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
# store a text (utf8 string)
system.file('my-file.txt').save_text_content('text content')
# read as base64
assert system.file('my-file.txt').get_base64_content() == 'dGV4dCBjb250ZW50'
# store bytes data
system.file('my-file.dat').save_bytes_content(b'bytes data äöü')
# read as text (utf8 string)
assert system.file('my-file.dat').get_text_content() == 'bytes data äöü'
# store a base64 encoded string
system.file('my-file.ext').save_base64_content('Q2xvdWRvbWF0aW9u')
# read as bytes
assert system.file('my-file.ext').get_bytes_content() == b'Cloudomation'
# list files
for file_ in system.files():
this.log(file_.get('name', 'size_bytes'))
# clean up
system.file('my-file.txt').delete()
system.file('my-file.dat').delete()
system.file('my-file.ext').delete()
return this.success('all done')
See the corresponding Flow Api class at File
Property | Description | Type | Import/Export |
---|---|---|---|
content | The binary content of the file. | BYTEA() | both |
created_at | DateTime(timezone=True) | export only | |
created_by | UUID() | export only | |
deleted_at | DateTime(timezone=True) | export only | |
deleted_by | UUID() | export only | |
description | Text() | both | |
id | UUID() | neither | |
is_archived | Boolean() | both | |
is_opened | Boolean() | neither | |
is_pinned | Boolean() | neither | |
is_readonly | Boolean() | both | |
modified_at | DateTime(timezone=True) | export only | |
modified_by | UUID() | export only | |
name | String(length=128) | both | |
organization_id | UUID() | export only | |
project_id | UUID() | both | |
record_type | Enum('CONNECTOR', 'FILE', 'FLOW', 'GIT_CONFIG', 'IDENTITY', 'OAUTH', 'ORGANIZATION', 'PLUGIN', 'PROJECT', 'RESOURCE', 'ROLE', 'SCHEDULE', 'SCHEDULER', 'SCHEMA', 'SEARCH', 'SETTING', 'SYNC_CONFIG', 'TAG', 'USER', 'VAULT_CONFIG', 'WEBHOOK', 'WORKSPACE', 'WRAPPER', 'RESOURCE_WRAPPER', 'EXECUTION', 'MESSAGE', 'PROCESS', name='tabletype') | neither | |
resource_type | Enum('CONNECTOR', 'FILE', 'FLOW', 'GIT_CONFIG', 'OAUTH', 'ORGANIZATION', 'PLUGIN', 'PROJECT', 'ROLE', 'SCHEDULE', 'SCHEDULER', 'SCHEMA', 'SEARCH', 'SETTING', 'SYNC_CONFIG', 'TAG', 'USER', 'VAULT_CONFIG', 'WEBHOOK', 'WORKSPACE', 'WRAPPER', 'RESOURCE_WRAPPER', name='resourcetype') | neither | |
size_bytes | BigInteger() | neither | |
workspace_id | UUID() | export only |