1.1.1 • Published 5 years ago

cloud-uploader v1.1.1

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

Node.js Cloud storage file uploader

Painless file uploader to cloud storages for Node.js

Install

npm i -S cloud-uploader

Config

make sure initilize upload you can use s3 or google cloud storage and make sure you pass configs for selected provder place these pease of code in your index.js or whatever is your main .js file

const Uploader = require('uploader')
Uploader.init({ drive: 'amazon', config: {} })

config for Amazon S3

accessKeyId: 'XXXXXXXXXXXXXXXX',
secretAccessKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
region: 'eu-west-3', // choose best for you
version: 'v4',
bucket: 'bucket-name'

Usage

Upload file

const remotePath = `remote/path/filename`
const localPath = `usr/local/filename`
const result = await Uploader.upload(localPath, remotePath)

Upload file base64

const remotePath = `remote/path/filename`
const imageData = 'data:image/gif;base64,R0lGODlhPQBEAPeoAJosM//AwO/AwHVYZ/z595kzAP/s7.....'
const result = await Uploader.upload(null, remotePath, { base64: imageData })

Get file url

const url = Uploader.getUrl(remotePath)

Delete file

await Uploader.deleteFile(remotePath)
1.1.1

5 years ago

1.1.0

5 years ago