@spica-devkit/storage
Upload, download, list, rename, replace and delete storage objects from browsers, Node.js and functions.
Terminal
npm install @spica-devkit/storageTypeScript
import * as Storage from "@spica-devkit/storage";
Storage.initialize({apikey: process.env.SPICA_API_KEY, publicUrl: "https://api.example.com/api"});Upload
In a browser, pass File objects. In Node.js, pass buffers with a name and content type:
TypeScript
// Browser
const input = document.querySelector<HTMLInputElement>("input[type=file]");
const objects = await Storage.insertMany(input.files, progress =>
console.log(Math.round((progress.loaded / progress.total) * 100), "%")
);
// Node.js or functions
const object = await Storage.insert({
name: "reports/2026-11.csv",
contentType: "text/csv",
data: Buffer.from(csv)
});
object.url;API
| Function | Description |
|---|---|
insert(file, onUploadProgress?) | Upload one object. |
insertMany(files, onUploadProgress?) | Upload several objects. |
get(id) | Get an object's metadata. |
getAll(queryParams?) | List objects. Accepts filter, sort, limit, skip, paginate. |
download(id, {onDownloadProgress?}) | Download the content: a Blob in browsers, a stream in Node.js. |
update(id, file, onUploadProgress?) | Replace the content. |
updateMeta(id, {name}) | Rename. |
remove(id), removeMany(ids) | Delete objects. |
TypeScript
const stream = await Storage.download(object._id);
stream.pipe(fs.createWriteStream("report.csv"));Storage endpoints accept identities and API keys. See Storage for strategies, folders and access control.