file-cloud-storage
v1.6.0
Published
A set of wrappers for S3 clients
Downloads
2
Readme
File Cloud Storage
Install
$ npm install file-cloud-storage
Functions
getContent(bucket, fileName)
returns a promise resolved to the file contentuploadFile(bucket, fileName, filePath)
returns a promiseuploadText(bucket, fileName, content)
returns a promise
Usage
import getS3Client from 'file-cloud-storage';
const bucket = 'files';
const fileName = 'test.txt';
const endpoint = '<endpoint>';
(async () => {
try {
const { getContent, uploadFile, uploadText } = await getS3Client('ibm', { apiKeyId: '<apiKey>', endpoint });
await uploadFile(bucket, 'test.mp3', './files/test.mp3');
await uploadText(bucket, fileName, 'test content');
const fileContent = await getContent(bucket, fileName);
console.log(fileContent);
} catch (e) {
console.error(e);
}
})();