Skip to content
Source
Sign inSign up

PutObject.ts

38 lines1.1 KB

1import * as S3 from "@distilled.cloud/aws/s3";
2import * as Binding from "alchemy/Binding";
3import * as Effect from "effect/Effect";
4import type { Bucket } from "./Bucket.ts";
5​
6export interface PutObjectRequest extends Omit<S3.PutObjectRequest, "Bucket"> {}
7​
8/**
9 * Runtime binding for `s3:PutObject`.
10 *
11 * Bind this operation to a bucket to get a callable that writes objects without
12 * manually supplying the bucket name on every request. `s3:PutObject` is
13 * granted on the bucket automatically. Provide the implementation with
14 * `Effect.provide(AWS.S3.PutObjectHttp)`.
15 * ### Writing Objects
16 * **Example:** Put an Object
17 * ```typescript
18 * const putObject = yield* PutObject(bucket);
19 *
20 * yield* putObject({
21 * Key: "hello.txt",
22 * Body: "Hello, world!",
23 * ContentType: "text/plain",
24 * });
25 * ```
26 *
27 * @binding
28 */
29export interface PutObject extends Binding.Service<
30 PutObject,
31 "AWS.S3.PutObject",
32 (
33 bucket: Bucket,
34 ) => Effect.Effect<
35 (request: PutObjectRequest) => Effect.Effect<S3.PutObjectOutput, S3.PutObjectError>
36 >
37> {}
38export const PutObject = Binding.Service<PutObject>("AWS.S3.PutObject");