ovh-iconlib-provider-storage
v0.3.0
Published
Storage provider
Downloads
9
Readme
Icon Library - Storage Provider
Storage Provider used to define a contract for all storage process in the Icon Library project.
StorageBaseProvider
Methods to implement
abstract
class
StorageBaseProviderabstract
function
list(string
path,number
skip,number
take)abstract
function
upload(Stream
stream,Object
options)abstract
function
download(string
filepath)abstract
function
remove(string
filepath)
Implementations
- oss (ovh-iconlib-provider-storage-oss)
License
See LICENSE
file
OSS example
Installation
npm install --save ovh-iconlib-provider-storage ovh-iconlib-provider-storage-oss
Configuration
# config.yml
---
connections:
-
name: test
authUrl: ${OSS_AUTH_URL}
username: ${OSS_USERNAME}
password: ${OSS_PASSWORD}
region: ${OSS_REGION}
container: ${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();
// get files
storage.list()
.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 => {
...
});