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