@mayurajs/filestorage-r2
v1.2.0
Published
Cloudflare R2 through a Workers binding, for Mayura's file stores.
Readme
@mayurajs/filestorage-r2
Cloudflare R2 through a Workers binding, for Mayura's file stores (mayura/files).
npm install mayura @mayurajs/filestorage-r2import { createFileStore } from 'mayura/files';
import { r2Files } from '@mayurajs/filestorage-r2';
export default {
async fetch(request: Request, env: { FILES: R2Bucket }) {
const files = createFileStore(r2Files({ bucket: env.FILES }), { maxFileBytes: 10 * 1024 * 1024 });
// ...
},
};- No keys, endpoints or signing: the binding is the credential.
ifMatchandifNoneMatchare R2's own preconditions. The binding cannot delete conditionally, so the store'sconditionalDeleteis false and a conditional delete is refused.- Outside Workers, reach R2 over its S3 API with
s3Filesinmayura/files(region: 'auto'). - Passes Mayura's file store conformance suite on R2 in Miniflare.
See the files guide. Apache-2.0.
