Flect store
Flect · Object storage
Section titled “Flect · Object storage”Part of the flect skill set.
What it is
Section titled “What it is”Flect object stores are S3-compatible, powered by
Garage. Each store is its own bucket with its
own API key pair. env.store(binding) returns an official
@aws-sdk/client-s3
S3Client, pre-configured with the endpoint, region, and credentials.
Create
Section titled “Create”flect store create my-uploadsflect store listflect store status <ref>flect store delete <ref>[[stores]]binding = "FILES"name = "my-uploads"Use in code
Section titled “Use in code”import { createEnv } from '@getflect/sdk'import { PutObjectCommand, GetObjectCommand, DeleteObjectCommand } from '@aws-sdk/client-s3'
const env = createEnv()const s3 = await env.store('FILES') // configured S3Clientconst Bucket = process.env.FILES_BUCKET! // the resolved bucket name (<BINDING>_BUCKET)
await s3.send(new PutObjectCommand({ Bucket, Key: 'hello.txt', Body: 'Hello, Flect!', ContentType: 'text/plain' }))const { Body } = await s3.send(new GetObjectCommand({ Bucket, Key: 'hello.txt' }))const text = await Body?.transformToString()await s3.send(new DeleteObjectCommand({ Bucket, Key: 'hello.txt' }))The bucket name is not the binding — read it from process.env.<BINDING>_BUCKET.
It’s the real S3Client, so use official commands, not store.put().
Presigned URLs (direct browser upload/download)
Section titled “Presigned URLs (direct browser upload/download)”import { getSignedUrl } from '@aws-sdk/s3-request-presigner'import { PutObjectCommand } from '@aws-sdk/client-s3'
const url = await getSignedUrl( s3, new PutObjectCommand({ Bucket, Key: `uploads/${filename}`, ContentType: type }), { expiresIn: 300 },)Isolation
Section titled “Isolation”Each store has its own Garage API key, scoped to its own bucket — a key for store
A cannot touch store B. Garage requires path-style addressing, which the resolved
client already sets (forcePathStyle: true).
Local development
Section titled “Local development”flect dev # createEnv() resolves the store locallydocker run -d -p 9000:9000 -p 9001:9001 \ -e MINIO_ROOT_USER=minioadmin -e MINIO_ROOT_PASSWORD=minioadmin \ quay.io/minio/minio server /data --console-address ":9001"Set S3_ENDPOINT, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY (see
Local development) and create the bucket in the MinIO
console at http://localhost:9001.
Related skills
Section titled “Related skills”- flect-app · flect.
- flect-pages — for serving a whole static site.