Skip to content

GetObject

Source: src/AWS/S3/GetObject.ts

Runtime binding for s3:GetObject.

Bind this operation to a bucket in the function’s init phase to get a callable that reads objects — the bucket name is injected automatically and s3:GetObject is granted on the bucket. Provide the implementation with Effect.provide(AWS.S3.GetObjectHttp).

Read an Object and Decode Its Body

// init — bind the operation to the bucket
const getObject = yield* AWS.S3.GetObject(bucket);
// runtime — the Body is a Stream; decode it to a string
const text = yield* getObject({ Key: "jobs/job-123.json" }).pipe(
Effect.flatMap((result) =>
Stream.mkString(Stream.decodeText(result.Body!)),
),
);

Treat a Missing Key as Absence

const job = yield* getObject({ Key: `jobs/${jobId}.json` }).pipe(
Effect.catchTag("NoSuchKey", () => Effect.succeed(undefined)),
);