stack-client

0.2.0 • Public • Published

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

Dependencies (1)

Dev Dependencies (3)

Package Sidebar

Install

npm i stack-client

Weekly Downloads

3

Version

0.2.0

License

MIT

Unpacked Size

537 kB

Total Files

6

Last publish

Collaborators

  • coldrift