Bucket
Source:
src/Fly/Bucket.ts
A Fly.Bucket is Tigris S3-compatible object storage, billed through
Fly. It is an org-scoped GraphQL add-on (AddOnType tigris).
Create a Bucket
Section titled “Create a Bucket”Alchemy generates a unique name unless you pass one.
const data = yield* Fly.Bucket("Data");A stable name
Section titled “A stable name”Pass name when you need a stable Tigris bucket name.
const data = yield* Fly.Bucket("Data", { name: "my-bucket",});Organization
Section titled “Organization”Org defaults to the current token. Pass orgSlug to pin it.
const data = yield* Fly.Bucket("Data", { orgSlug: "my-org",});Public access
Section titled “Public access”Buckets are private by default. public: true serves objects
without credentials.
const assets = yield* Fly.Bucket("Assets", { public: true,});Custom domain
Section titled “Custom domain”domainName sets website.domain_name on the add-on. Point a
CNAME at {name}.t3.tigrisbucket.io.
const assets = yield* Fly.Bucket("Assets", { public: true, domainName: "assets.example.com",});Put and get objects
Section titled “Put and get objects”Tigris speaks the S3 API. Bind PutObject / GetObject
(and the other S3 object ops) in Service init. Alchemy injects the
Tigris endpoint and credentials; you never read AWS_* yourself.
import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
export default class Api extends Fly.Service<Api>()( "Api", { app: Site, main: import.meta.url, port: 3000 }, Effect.gen(function* () { const putObject = yield* Fly.PutObject(Data); const getObject = yield* Fly.GetObject(Data);
return { fetch: Effect.gen(function* () { yield* putObject({ Key: "hello.txt", Body: "hello", ContentType: "text/plain", }); const obj = yield* getObject({ Key: "hello.txt" }); return HttpServerResponse.json({ ok: obj.ETag !== undefined }); }), }; }).pipe(Effect.provide([Fly.PutObjectHttp, Fly.GetObjectHttp])),) {}Fly.Secret
Section titled “Fly.Secret”You can also set each key yourself with Secret.
yield* Fly.Secret("BucketName", { app: Site, name: "BUCKET_NAME", value: Data.bucketName,});