Python SDK: Storage: files and links
ctx.storage(code) accesses a configured storage connection. All file and link operations are synchronous.
Examples are fragments inside def run(ctx):. All SDK methods are synchronous; do not add await.
Methods
put_from_url
ctx.storage('media').put_from_url(url, key=None, mime=None) -> StoredFile
| Argument | Type | Required | Purpose |
|---|---|---|---|
url |
str |
Yes | Permitted source HTTP(S) URL. |
key |
str | None |
No, see the signature default | Record, state, object, or workflow-input key, depending on the method. |
mime |
str | None |
No, see the signature default | Content type of the stored file. |
Result: StoredFile. An SDK object; use its methods instead of emitting it directly.
Copies a file from an allowed URL and returns a StoredFile SDK object with saved-file properties.
result = ctx.storage('media').put_from_url(ctx.param('image_url'), 'images/item.jpg')
put
ctx.storage('media').put(key, content, mime='text/plain') -> StoredFile
| Argument | Type | Required | Purpose |
|---|---|---|---|
key |
str | None |
Yes | Record, state, object, or workflow-input key, depending on the method. |
content |
str | bytes |
Yes | Supplied content; method limits apply. |
mime |
str | None |
No, see the signature default | Content type of the stored file. |
Result: StoredFile. An SDK object; use its methods instead of emitting it directly.
Saves content in the configured storage. Returns a StoredFile SDK object. Read result.key, result.size, and result.dry_run.
result = ctx.storage('media').put('reports/summary.txt', 'Ready', 'text/plain')
exists
ctx.storage('media').exists(key) -> bool
| Argument | Type | Required | Purpose |
|---|---|---|---|
key |
str | None |
Yes | Record, state, object, or workflow-input key, depending on the method. |
Result: bool.
Check whether a dictionary exists under a key.
result = ctx.storage('media').exists('reports/summary.txt')
url
ctx.storage('media').url(key, ttl_seconds=3600) -> str
| Argument | Type | Required | Purpose |
|---|---|---|---|
key |
str | None |
Yes | Record, state, object, or workflow-input key, depending on the method. |
ttl_seconds |
int |
No, see the signature default | Signed URL lifetime, seconds. |
Result: str.
Get a temporary signed link to a dictionary.
result = ctx.storage('media').url('reports/summary.txt', 3600)
Errors and execution context
All calls are synchronous. Invalid arguments or malformed source data can raise ValueError/TypeError; a platform refusal or unavailable service raises RuntimeError. Missing elements/values return None or an empty collection only where explicitly documented. Do not convert every exception into an empty successful result. External-service methods are unavailable in export transformations; see transformation limits and environment.