2.1.1 • Published 2 years ago
multer-aliyun-oss v2.1.1
Multer Storage for AliYun OSS
Dependencies @ali-oss
Install
npm install --save multer-aliyun-oss
Usage
const multer = require('multer');
const MAO = require('multer-aliyun-oss');
const upload = multer({
storage: MAO({
config: {
region: '<region>',
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: '<bucket>',
},
// to set path prefix for files, could be string or function
destination: ''
})
});
File information
Each file contains the following information:
Key | Description | Note |
---|---|---|
fieldname | Field name specified in the form | |
originalname | Name of the file on the user's computer | |
encoding | Encoding type of the file | |
mimetype | Mime type of the file | |
size | Size of the file in bytes | |
destination | The folder to which the file has been saved | DiskStorage |
filename | The name of the file within the destination | DiskStorage |
path | The full path to the uploaded file | DiskStorage |
buffer | A Buffer of the entire file | MemoryStorage |
Option
destination
String
or Function
// same signature as multer native
destination (req, file, callback) {
callback(null, 'images')
}