r2-file-storage 1.0.2
Install from the command line:
Learn more about npm packages
$ npm install @edgefirst-dev/r2-file-storage@1.0.2
Install via package.json:
"@edgefirst-dev/r2-file-storage": "1.0.2"
About this version
An implementation of @mjackson/file-storage that uses R2 as the storage backend.
- Simple, intuitive key/value API (like Web Storage, but for
File
s instead of strings) - A generic
FileStorage
class that works for various Cloudflare R2. - Preserves all
File
metadata includingfile.name
,file.type
, andfile.lastModified
Install from npm or GitHub Package Registry with;
bun add @edgefirst-dev/r2-file-storage
import { R2FileStorage } from "@edgefirst-dev/r2-file-storage";
let storage = new R2FileStorage(r2); // Get r2 from your Cloudflare bindings
let file = new File(["hello world"], "hello.txt", { type: "text/plain" });
let key = "hello-key";
// Put the file in storage.
await storage.set(key, file);
// Then, sometime later...
let fileFromStorage = await storage.get(key);
// All of the original file's metadata is intact
fileFromStorage.name; // 'hello.txt'
fileFromStorage.type; // 'text/plain'
// To remove from storage
await storage.remove(key);
See LICENSE
Details
- r2-file-storage
- edgefirst-dev
- 13 days ago
- MIT
- 10 dependencies
Assets
- r2-file-storage-1.0.2.tgz
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0