1.1.1 • Published 6 years ago
softlayer-object-storage v1.1.1
SoftLayer Object Storage helper
Installing
NPM
$ npm i -S softlayer-object-storage
Code
import ObjectStorage from 'softlayer-object-storage';
import fs from 'fs';
const conf = {
timeout: 1000 * 60 * 10, // connection timeout [optional]
removeAccess: true, // allow remove objects from container [default false]
storage: 'public', // public or private
endpoint: 'https://***.objectstorage.softlayer.net/auth/v1.0',
username: 'SLOS********-*:***********',
key: '******************************',
container: 'backups',
};
const backupsContainer = new ObjectStorage(conf);
const readStream = fs.createReadStream('./mysql.sql.gz');
// create new containers 'test-container'
backupsContainer.createContainer('test-container')
.then(console.log)
.catch(console.error);
// show all containers in your account
backupsContainer.listContainers()
.then(console.log)
.catch(console.error);
// remove container, (you can remove only empty container)
backupsContainer.removeContainer('test-container')
.then(console.log)
.catch(console.error);
// show full url to all files in 'backups' container
// show full url to all files in folder 'public' of 'backups' container: backupsContainer.listFiles('/public')
backupsContainer.listFiles()
.then(console.log)
.catch(console.error);
// upload 'mysql.sql.gz' from local to OS
// if you are passing stream from spawn (with no name)
// 'backupsContainer.uploadFile(readStream, { name: 'custom file name', container, headers: 'object to extent put headers' })'
// or you can even just pass the path 'backupsContainer.uploadFile('./mysql.sql.gz')'
backupsContainer.uploadFile(readStream)
.then(console.log)
.catch(console.error);
// remove 'mysql.sql.gz' from OS
// you can pass string (to remove one object) or array of string to remove many
// string is a a name or full URL to object
backupsContainer.removeFile('mysql.sql.gz') // or backupsContainer.removeFile('https://***.objectstorage.softlayer.net/v1/AUTH_**/backups/mysql.sql.gz')
.then(console.log)
.catch(console.error);
License
MIT
1.1.1
6 years ago
1.1.0
6 years ago
1.0.22
7 years ago
1.0.21
7 years ago
1.0.20
7 years ago
1.0.19
7 years ago
1.0.18
7 years ago
1.0.17
7 years ago
1.0.16
7 years ago
1.0.15
7 years ago
1.0.14
7 years ago
1.0.13
7 years ago
1.0.12
7 years ago
1.0.11
7 years ago
1.0.10
7 years ago
1.0.9
7 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago