Skip to main content

S3.Get

Examples below assume this module is imported with an imports: entry under alias S3. Kind references (S3.Get, S3.Bucket) follow that alias — if you import the module under a different name, substitute your alias accordingly.

Streams an object's bytes from a bucket declared as S3.Bucket. Invocable — emits output as an async iterable of Uint8Array chunks, so downstream consumers stay byte-streaming end-to-end.

The result's output property is annotated with x-telo-stream: true. Pair it with an Encoder (e.g. Octet.Encoder for raw bytes) when wiring through an Http.Api response so the body never buffers in memory.


Example

Streaming an S3 object straight onto an HTTP response:

- request:
path: /{namespace}/{name}/{version}/telo.yaml
method: GET
handler:
kind: S3.Get
bucketRef: !ref ModuleStore
inputs:
key: "${{ request.params.namespace + '/' + request.params.name + '/' + request.params.version + '/telo.yaml' }}"
returns:
- status: 200
mode: stream
content:
text/yaml:
encoder: { kind: Octet.Encoder }

Iterating the byte stream inside a sequence:

- name: fetchManifest
invoke:
kind: S3.Get
bucketRef: !ref ModuleStore
inputs:
key: "${{ inputs.fileKey }}"
- name: drain
invoke:
kind: JS.Script
name: CollectBytes
inputs:
chunks: "${{ steps.fetchManifest.result.output }}"

Fields

FieldTypeRequiredDescription
bucketRefreferenceyesA !ref to an S3.Bucket resource — local (!ref ModuleStore) or imported (!ref Alias.ModuleStore).

Invocation inputs

InputTypeRequiredDescription
keystringyesObject key (path inside the bucket).

Output

FieldTypeDescription
outputStream<Uint8Array>Async iterable of byte chunks streamed from the storage backend.
contentTypestringContent-Type header reported by the storage backend, when available.

Errors

CodeWhen
ERR_NOT_FOUNDThe object does not exist under the given key.
ERR_INVALID_REFERENCEbucketRef does not resolve to a live S3.Bucket resource.
ERR_INVALID_RESPONSEThe storage backend returned no iterable body.