1.0.5 • Published 6 years ago

upload-cloud-storage v1.0.5

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

Upload files to Cloud Storage

Geting Started

  • Easy to upload your files to google static
  • Support auto-download file from url and upload it to your cloud :))

Installing

npm i --save upload-cloud-storage

or

yarn add upload-cloud-storage

Usage

import Storage from 'upload-cloud-storage'
//const Storage = require('upload-cloud-storage')

import path from 'path'

const Google = Storage.init({

	type: 'google',
	keyFilename: path.resolve(__dirname, 'gg.json'),
	bucketName: 'your bucket name',
	projectId: 'your project id',',
})

Google.upload(filepath, {

	deleteSource: true,
	contentType: 'image/jpeg',
	newName: 'test.jpg',
	dest: 'test'

}).then(result => {

	console.log(result) //result contain metadata of file

}).catch(err => console.log(err))
  • filepath: can be url (http://...) or file path in your disk
  • it will auto-download file if url

Option fields

FieldUseDefaultOptional
newNameset new file namesame original file nametrue
destsub dir in bucketbucket roottrue
contentTypenew content-type for filesame original file typetrue
deleteSourcedelete source file on finish uploadingfalsetrue