The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import { Files, UploadError } from "./Files.ts"; |
| 5 | |
| 6 | // #region show |
| 7 | export const FilesS3 = Layer.effect( |
| 8 | Files, |
| 9 | Effect.gen(function* () { |
| 10 | const bucket = yield* AWS.S3.Bucket("Files"); |
| 11 | const putObject = yield* AWS.S3.PutObject(bucket); |
| 12 | |
| 13 | return { |
| 14 | upload: (name: string, body: string) => |
| 15 | putObject({ Key: name, Body: body }) /*hide*/ |
| 16 | .pipe( |
| 17 | Effect.asVoid, |
| 18 | Effect.mapError((cause) => new UploadError({ cause })), |
| 19 | ) /*end*/, |
| 20 | }; |
| 21 | }), |
| 22 | ) /*hide*/ |
| 23 | .pipe(Layer.provide(AWS.S3.PutObjectHttp)); /*end*/ |
| 24 | // #endregion show |