| 1 | import * as Effect from "effect/Effect"; |
| 2 | import * as Stream from "effect/Stream"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { RuntimeContext } from "../../RuntimeContext.ts"; |
| 5 | import type { Bucket } from "./Bucket.ts"; |
| 6 | import type { |
| 7 | Conditional, |
| 8 | R2Error, |
| 9 | MultipartOptions, |
| 10 | MultipartUpload, |
| 11 | R2Object, |
| 12 | PutOptions, |
| 13 | } from "./BucketTypes.ts"; |
| 14 | |
| 15 | /** |
| 16 | * @binding |
| 17 | * @product R2 |
| 18 | * @category Storage & Databases |
| 19 | */ |
| 20 | export interface WriteBucket extends Binding.Service< |
| 21 | WriteBucket, |
| 22 | "Cloudflare.R2.WriteBucket", |
| 23 | (bucket: Bucket) => Effect.Effect<WriteBucketClient> |
| 24 | > {} |
| 25 | |
| 26 | export const WriteBucket = Binding.Service<WriteBucket>( |
| 27 | "Cloudflare.R2.WriteBucket", |
| 28 | ); |
| 29 | |
| 30 | export interface WriteBucketClient { |
| 31 | put<Err = never>( |
| 32 | key: string, |
| 33 | value: |
| 34 | | ReadableStream |
| 35 | | ArrayBuffer |
| 36 | | ArrayBufferView |
| 37 | | string |
| 38 | | null |
| 39 | | Blob |
| 40 | | Stream.Stream<Uint8Array, Err>, |
| 41 | options?: PutOptions & { |
| 42 | onlyIf: Conditional | Headers; |
| 43 | contentLength?: number; |
| 44 | }, |
| 45 | ): Effect.Effect<R2Object | null, R2Error | Err, RuntimeContext>; |
| 46 | put<Err = never>( |
| 47 | key: string, |
| 48 | value: |
| 49 | | ReadableStream |
| 50 | | ArrayBuffer |
| 51 | | ArrayBufferView |
| 52 | | string |
| 53 | | null |
| 54 | | Blob, |
| 55 | options?: PutOptions, |
| 56 | ): Effect.Effect<R2Object, R2Error | Err, RuntimeContext>; |
| 57 | put<Err = never>( |
| 58 | key: string, |
| 59 | value: |
| 60 | | ReadableStream |
| 61 | | ArrayBuffer |
| 62 | | ArrayBufferView |
| 63 | | string |
| 64 | | null |
| 65 | | Blob |
| 66 | | Stream.Stream<Uint8Array, Err>, |
| 67 | options: PutOptions & { |
| 68 | contentLength: number; |
| 69 | }, |
| 70 | ): Effect.Effect<R2Object, R2Error | Err, RuntimeContext>; |
| 71 | delete(keys: string | string[]): Effect.Effect<void, R2Error, RuntimeContext>; |
| 72 | createMultipartUpload( |
| 73 | key: string, |
| 74 | options?: MultipartOptions, |
| 75 | ): Effect.Effect<MultipartUpload, R2Error, RuntimeContext>; |
| 76 | resumeMultipartUpload( |
| 77 | key: string, |
| 78 | uploadId: string, |
| 79 | ): Effect.Effect<MultipartUpload, R2Error, RuntimeContext>; |
| 80 | } |