0.2.0 • Published 4 years ago

stack-client v0.2.0

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

node Stack client

This is a node.js client for TransIP Stack cloud storage

Installation

$ npm install --save stack-client

Example

const fs = require('fs');
const zlib = require('zlib');

const StackClient = require('stack-client');

const client = new StackClient('https://example.stackstorage.com', 'user', 'pass');

const outputStream = client.createWriteStream('test.txt.gz', (err, res) => {
  console.log('done writing!')
})

const inputStream = fs.createReadStream('test.txt');

const gzip = zlib.createGzip({level: 3});

gzip.pipe(outputStream)
inputStream.pipe(gzip)

API

Instantiating

Instantiate the stack client by passing the base URL of your Stack, the username, the password:

const StackClient = require('stack-client');

const client = new StackClient('https://example.stackstorage.com', 'user', 'pass');

Writing files

Use createWriteStream(path, cb) to create a writiable stream into a file under specified path:

const fs = require('fs');
const zlib = require('zlib');


[...]

const outputStream = client.createWriteStream('test.txt.gz')
const inputStream = fs.createReadStream('test.txt');

const gzip = zlib.createGzip({level: 3});

gzip.pipe(outputStream)
inputStream.pipe(gzip)

Creating folders

Use mkdir(path) to create a folder within your Stack:

await client.mkdir('test')
await client.mkdir('test/test')

Removing files and folders

Use delete(path) to remove files and folders:

await client.remove('test/test')
await client.remove('test')

License

Licensed under MIT License. Copyright (C) 2019 Coldrift Technologies B.V. All rights reserved.

Maintenance and support

Visit the company's website

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago