multer-google-drive
v1.0.3
Published
Tạo google drive storage cho upload file sử dụng multer.
Downloads
100
Maintainers
Readme
Multer google drive
Engine lưu trữ cho Multer sử dụng Google Drive API.
Cài đặt
npm install --save multer-google-drive
Cách sử dụng
var {google} = require('googleapis')
var express = require('express')
var multer = require('multer')
var GoogleDriveStorage = require('multer-google-drive')
var app = express()
var drive = google.drive({version: 'v3', auth: /*.....*/})
var upload = multer({
storage: GoogleDriveStorage({
drive: drive,
parents: 'id-parents',
fileName: function (req, file, cb) {
let filename = `test-${file.originalname}`;
cb(null, filename);
}
})
})
app.post('/upload', upload.array('file', 3), function(req, res, next) {
res.send('Upload thành công ' + req.files.length + ' files!')
})