@forinda/kickjs-storage
v0.4.0
Published
File storage for KickJS — one interface over memory, local disk, and S3-compatible buckets (AWS S3, Cloudflare R2, MinIO), with signed URLs and no SDK
Maintainers
Readme
@forinda/kickjs-storage
File storage for KickJS — one Storage interface over memory, local disk, and S3-compatible buckets (AWS S3, Cloudflare R2, MinIO), with signed URLs and no AWS SDK.
Install
kick add storageThis writes src/storage.ts and adds storageAdapter() to bootstrap(). Files go to uploads/ until S3_BUCKET is set. Inject the storage with @Autowired(STORAGE).
Quick Example
import { s3Storage } from '@forinda/kickjs-storage' // Node, Bun, Deno, Workers
import { diskStorage } from '@forinda/kickjs-storage/disk' // Node
const files =
process.env.NODE_ENV === 'production'
? s3Storage({
bucket: 'avatars',
region: 'eu-west-1',
accessKeyId: process.env.S3_ACCESS_KEY_ID!,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY!,
})
: diskStorage({ root: './uploads', baseUrl: '/uploads' })
await files.put('avatars/42.png', ctx.file!.buffer, { contentType: 'image/png' })
const link = await files.url('avatars/42.png', { expiresIn: 600 }) // presigned on S3From the environment (S3_BUCKET, S3_ACCESS_KEY_ID, …), validated at startup:
import { S3Settings, s3FromSettings } from '@forinda/kickjs-storage/settings'
bootstrap({ modules, settings: [S3Settings] })
const files = s3FromSettings()Resumable uploads through your server, for tus-js-client and Uppy:
import { TusAdapter } from '@forinda/kickjs-storage/tus'
bootstrap({ modules, adapters: [TusAdapter({ path: '/api/uploads', storage: files })] })Documentation
License
MIT
