0.3.0 • Published 8 years ago
ovh-iconlib-provider-storage v0.3.0
Icon Library - Storage Provider
Storage Provider used to define a contract for all storage process in the Icon Library project.
StorageBaseProvider
Methods to implement
abstractclassStorageBaseProviderabstractfunctionlist(stringpath,numberskip,numbertake)abstractfunctionupload(Streamstream,Objectoptions)abstractfunctiondownload(stringfilepath)abstractfunctionremove(stringfilepath)
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-ossConfiguration
# 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: testUsage
// 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 => {
...
});