Skip to content

cloud-cli/storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

268b3e7 · Jul 8, 2024

History

55 Commits
Jan 9, 2024
May 15, 2024
Dec 21, 2023
Dec 18, 2023
Dec 18, 2023
Jul 8, 2024
Jan 22, 2024
May 15, 2024
May 15, 2024
Jan 22, 2024
Mar 11, 2024
Jan 5, 2024

Repository files navigation

File storage service

A file bin service for all your quick and easy storage needs.

API

See api.yaml for API specification.

Usage

With docker

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.

As a standalone server with Node.JS

import start from '@cloud-cli/storage';

start({ rootDir: process.cwd() + '/data', port: 1234 });

As an ESM Module

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();

Environment variables

env description
ROOT_DIR String. Path to a folder where all data is stored
PORT Number. HTTP port