0.0.3 • Published 10 months ago

@raabbajam/pluto-storage v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

pluto-storage

NPM version Build Status Coveralls Status Dependency Status Downloads

pluto-storage

Install

npm i -S pluto-storage

Usage

const plutoStorage = require('pluto-storage');
const {Client, Server} = plutoStorage;
const clientOptions = {
  serverUrl: 'localhost:3005',
  auth: 's3cret',
  downloadDir: '', // default to __dirname/.storage
};
const client = Client(clientOptions);
client.upload(filename) // Promise
  .then((url) => console.log(url)) // http://localhost:3006/download/2016/09/26/013f2580-9cc2-48ed-973f-d2be4950e72b
client.uploadPublic(filename); // Promise
client.uploadPublic(readableStream) // Promise
client.download(url, resultFile) // Promise
  .then(() => console.log('done downloading'));
client.download($url) // random localpath
  .then((localpath) => console.log(localpath));

const serverOptions = {
  serverUrl: 'localhost',
  port: '2001',
  auth: 's3cret',
  uploadDir: '', // default to __dirname/.storage
  enablePublic: '', // default to false
};
const server = Server(serverOptions);
Server.start() // Promise
  .then(() => console.log('listening on port'));
Server.stop() // Promise
  .then(() => console.log('stop listening'));

License

MIT © Raabb Ajam