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