Fly.Bucket reference
Bucket
Section titled “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).
Bucket: Create a Bucket
Section titled “Bucket: Create a Bucket”Alchemy generates a unique name unless you pass one.
const data = yield* Fly.Bucket("Data");Bucket: A stable name
Section titled “Bucket: A stable name”Pass name when you need a stable Tigris bucket name.
const data = yield* Fly.Bucket("Data", { name: "my-bucket",});Bucket: Organization
Section titled “Bucket: Organization”Org defaults to the current token. Pass orgSlug to pin it.
const data = yield* Fly.Bucket("Data", { orgSlug: "my-org",});Bucket: Public access
Section titled “Bucket: Public access”Buckets are private by default. public: true serves objects
without credentials.
const assets = yield* Fly.Bucket("Assets", { public: true,});Bucket: Custom domain
Section titled “Bucket: 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",});Bucket: Put and get objects
Section titled “Bucket: 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])),) {}Bucket: Fly.Secret
Section titled “Bucket: Fly.Secret”You can also set each key yourself with Secret.
yield* Fly.Secret("BucketName", { app: Site, name: "BUCKET_NAME", value: Data.bucketName,});DeleteObject
Section titled “DeleteObject”Source:
src/Fly/DeleteObject.ts
Runtime binding for Tigris DeleteObject over the S3 API.
Bind this operation to a Bucket in Service init. Provide
DeleteObjectHttp.
DeleteObject: Deleting Objects
Section titled “DeleteObject: Deleting Objects”const deleteObject = yield* Fly.DeleteObject(Data);yield* deleteObject({ Key: "hello.txt" });DeleteObjectHttp
Section titled “DeleteObjectHttp”Source:
src/Fly/DeleteObjectHttp.tsKind: Layer · Provides:Fly.DeleteObject
HTTP implementation of DeleteObject. Calls distilled S3
deleteObject against the Tigris endpoint with the bucket’s credentials.
GetObject
Section titled “GetObject”Source:
src/Fly/GetObject.ts
Runtime binding for Tigris GetObject over the S3 API.
Bind this operation to a Bucket in Service init. Provide
GetObjectHttp.
GetObject: Reading Objects
Section titled “GetObject: Reading Objects”const getObject = yield* Fly.GetObject(Data);
const text = yield* getObject({ Key: "hello.txt" }).pipe( Effect.flatMap((result) => Stream.mkString(Stream.decodeText(result.Body!)), ),);GetObjectHttp
Section titled “GetObjectHttp”Source:
src/Fly/GetObjectHttp.tsKind: Layer · Provides:Fly.GetObject
HTTP implementation of GetObject. Calls distilled S3
getObject against the Tigris endpoint with the bucket’s credentials.
HeadObject
Section titled “HeadObject”Source:
src/Fly/HeadObject.ts
Runtime binding for Tigris HeadObject over the S3 API.
Bind this operation to a Bucket in Service init. Provide
HeadObjectHttp.
HeadObject: Inspecting Objects
Section titled “HeadObject: Inspecting Objects”const headObject = yield* Fly.HeadObject(Data);const head = yield* headObject({ Key: "hello.txt" });HeadObjectHttp
Section titled “HeadObjectHttp”Source:
src/Fly/HeadObjectHttp.tsKind: Layer · Provides:Fly.HeadObject
HTTP implementation of HeadObject. Calls distilled S3
headObject against the Tigris endpoint with the bucket’s credentials.
ListObjectsV2
Section titled “ListObjectsV2”Source:
src/Fly/ListObjectsV2.ts
Runtime binding for Tigris ListObjectsV2 over the S3 API.
Bind this operation to a Bucket in Service init. Provide
ListObjectsV2Http.
ListObjectsV2: Listing Objects
Section titled “ListObjectsV2: Listing Objects”const listObjects = yield* Fly.ListObjectsV2(Data);const result = yield* listObjects({ Prefix: "jobs/", MaxKeys: 100 });ListObjectsV2Http
Section titled “ListObjectsV2Http”Source:
src/Fly/ListObjectsV2Http.tsKind: Layer · Provides:Fly.ListObjectsV2
HTTP implementation of ListObjectsV2. Calls distilled S3
listObjectsV2 against the Tigris endpoint with the bucket’s credentials.
PutObject
Section titled “PutObject”Source:
src/Fly/PutObject.ts
Runtime binding for Tigris PutObject over the S3 API.
Bind this operation to a Bucket in Service init. The Tigris
bucket name, endpoint, and credentials are injected automatically.
Provide PutObjectHttp.
PutObject: Writing Objects
Section titled “PutObject: Writing Objects”const putObject = yield* Fly.PutObject(Data);
yield* putObject({ Key: "hello.txt", Body: "Hello, world!", ContentType: "text/plain",});PutObjectHttp
Section titled “PutObjectHttp”Source:
src/Fly/PutObjectHttp.tsKind: Layer · Provides:Fly.PutObject
HTTP implementation of PutObject. Calls distilled S3
putObject against the Tigris endpoint with the bucket’s credentials.