Skip to content

ReadWriteBucket

Source: src/Prisma/ReadWriteBucket.ts

Bind a Prisma Object Store Bucket to a Prisma Compute app, AWS Lambda Function, or Cloudflare Worker with read and write access, and obtain the typed runtime client.

Binding creates a read-write Prisma.BucketAccessKey for the bucket and carries its S3 credentials into the host environment, so the caller never handles a credential themselves.

Provide ReadWriteBucketBinding on the host implementation.

Use ReadBucket instead where read-only access is enough: Prisma bucket keys have a read role, so that binding’s credential genuinely cannot write.

export default Prisma.Compute(
"api",
{ project, main: import.meta.filename },
Effect.gen(function* () {
const uploads = yield* Prisma.ReadWriteBucket(bucket);
return {
fetch: Effect.gen(function* () {
yield* uploads.put("hits", "1");
const object = yield* uploads.get("hits");
return yield* HttpServerResponse.text(
object === null ? "" : yield* object.text(),
);
}),
};
}).pipe(Effect.provide(Prisma.ReadWriteBucketBinding)),
);