ovh-iconlib-provider-storage-oss
v0.3.0
Published
OpenStack Storage provider
Downloads
9
Readme
Icon Library - OpenStack Storage
this module is an implementation of the base storage provider.
it uses the openstack part of pkgcloud.
Installation
ovh-iconlib-provider-storage
is a peer dependency.
npm install --save ovh-iconlib-provider-storage ovh-iconlib-provider-storage-oss
Configuration
# config.yml
---
connections:
-
name: test
authUrl: ${OSS_AUTH_URL} # process.env.OSS_AUTH_URL
username: ${OSS_USERNAME} # process.env.OSS_USERNAME
password: ${OSS_PASSWORD} # process.env.OSS_PASSWORD
region: ${OSS_REGION} # process.env.OSS_REGION
container: ${OSS_CONTAINER} # process.env.OSS_CONTAINER
storage:
default: oss
providers:
-
name: oss
type: ovh-iconlib-provider-storage-oss
connection: test
Usage
// default provider instance loaded according to the configuration
const storage = require('ovh-iconlib-provider-storage').getInstance();
// list 10 files from path/to/list
storage.list('path/to/list', 10, 10)
.then(files => {
files.forEach(file => {
...
});
});
// upload file
let stream = ...;
storage.upload(stream, {name: 'example.txt'})
.then(fileInfo => {
...
});
// remove file
storage.remove('example.txt')
.then(removed => {
...
});
// download file (get a readable stream)
let stream = storage.download('example.txt');
License
See LICENSE
file