| 1 | import type * as S3 from "@distilled.cloud/aws/s3"; |
| 2 | import type * as Config from "effect/Config"; |
| 3 | import type * as Effect from "effect/Effect"; |
| 4 | import * as Binding from "../Binding.ts"; |
| 5 | import type { RuntimeContext } from "../RuntimeContext.ts"; |
| 6 | import type { Bucket } from "./Bucket.ts"; |
| 7 | import type { RailwayS3CredentialsMissing } from "./BucketBinding.ts"; |
| 8 | |
| 9 | export interface PutObjectRequest extends Omit<S3.PutObjectRequest, "Bucket"> {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for Railway `PutObject` over the S3 API. |
| 13 | * |
| 14 | * Bind this operation to a {@link Bucket} in Service init. The bucket |
| 15 | * name, endpoint, and credentials are injected automatically. Provide |
| 16 | * {@link PutObjectHttp}. |
| 17 | * |
| 18 | * |
| 19 | * ### Writing Objects |
| 20 | * **Example:** Put an Object |
| 21 | * ```typescript |
| 22 | * const putObject = yield* Railway.PutObject(Data); |
| 23 | * |
| 24 | * yield* putObject({ |
| 25 | * Key: "hello.txt", |
| 26 | * Body: "Hello, world!", |
| 27 | * ContentType: "text/plain", |
| 28 | * }); |
| 29 | * ``` |
| 30 | * |
| 31 | * @binding |
| 32 | * @product Bucket |
| 33 | */ |
| 34 | export interface PutObject extends Binding.Service< |
| 35 | PutObject, |
| 36 | "Railway.PutObject", |
| 37 | ( |
| 38 | bucket: Bucket, |
| 39 | ) => Effect.Effect< |
| 40 | ( |
| 41 | request?: PutObjectRequest, |
| 42 | ) => Effect.Effect< |
| 43 | S3.PutObjectOutput, |
| 44 | S3.PutObjectError | Config.ConfigError | RailwayS3CredentialsMissing, |
| 45 | RuntimeContext |
| 46 | > |
| 47 | > |
| 48 | > {} |
| 49 | |
| 50 | export const PutObject = Binding.Service<PutObject>("Railway.PutObject"); |