1import * as S3 from "@distilled.cloud/aws/s3";
2import * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Bucket } from "./Bucket.ts";
5
6export interface AbortMultipartUploadRequest extends Omit<
7 S3.AbortMultipartUploadRequest,
8 "Bucket"
9> {}
10
11/**
12 * Runtime binding for `s3:AbortMultipartUpload`.
13 *
14 * Discards an in-progress multipart upload and frees the storage its parts
15 * consume — abandoned uploads keep billing until aborted (or expired by a
16 * lifecycle rule). Provide the implementation with
17 * `Effect.provide(AWS.S3.AbortMultipartUploadHttp)`.
18 * ### Multipart Uploads
19 * **Example:** Abort an Upload When Part Uploads Fail
20 * ```typescript
21 * // init — bind the operation to the bucket
22 * const abortUpload = yield* AWS.S3.AbortMultipartUpload(bucket);
23 *
24 * // runtime — clean up if the part-upload pipeline fails
25 * yield* uploadAllParts.pipe(
26 * Effect.tapError(() =>
27 * abortUpload({ Key: "backups/archive.tar", UploadId }),
28 * ),
29 * );
30 * ```
31 *
32 * @binding
33 */
34export interface AbortMultipartUpload extends Binding.Service<
35 AbortMultipartUpload,
36 "AWS.S3.AbortMultipartUpload",
37 (
38 bucket: Bucket,
39 ) => Effect.Effect<
40 (
41 request: AbortMultipartUploadRequest,
42 ) => Effect.Effect<
43 S3.AbortMultipartUploadOutput,
44 S3.AbortMultipartUploadError
45 >
46 >
47> {}
48
49export const AbortMultipartUpload = Binding.Service<AbortMultipartUpload>(
50 "AWS.S3.AbortMultipartUpload",
51);