A file bin service for all your quick and easy storage needs.
See api.yaml
for API specification.
docker pull ghcr.io/cloud-cli/storage:latest
docker run --rm -e ROOT_DIR=/opt/data -e PORT=1234 -v$PWD/data:/opt/data ghcr.io/cloud-cli/storage:latest
See also the release page.
import start from '@cloud-cli/storage';
start({ rootDir: process.cwd() + '/data', port: 1234 });
Consuming it as an ESM module: if the server is running at https://bin.example.com
, import it as a module in a project:
import { createBin, createFile, writeFile, readFile } from 'https://bin.example.com/index.mjs';
async function save(content) {
const { binId } = await createBin();
const { fileId } = await createFile(binId);
return await writeFile(binId, fileId, content);
}
const { binId, fileID, url } = await save('hello');
const content = await readFile(binId, fileId);
// or directly
const hello = await (await fetch(url)).text();
env | description |
---|---|
ROOT_DIR | String. Path to a folder where all data is stored |
PORT | Number. HTTP port |