1import type * as S3 from "@distilled.cloud/aws/s3";
2import type * as Config from "effect/Config";
3import type * as Effect from "effect/Effect";
4import * as Binding from "../Binding.ts";
5import type { RuntimeContext } from "../RuntimeContext.ts";
6import type { Bucket } from "./Bucket.ts";
7import type { RailwayS3CredentialsMissing } from "./BucketBinding.ts";
8
9export 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 */
34export 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
50export const PutObject = Binding.Service<PutObject>("Railway.PutObject");