1.6.0 • Published 3 years ago

file-cloud-storage v1.6.0

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

File Cloud Storage

Install

$ npm install file-cloud-storage

Functions

  • getContent(bucket, fileName) returns a promise resolved to the file content
  • uploadFile(bucket, fileName, filePath) returns a promise
  • uploadText(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);
    }    
})();