如何把文件上传到阿里云的OSS存储
- npm一个支持阿里云oss存储的包
npm install --save multer-aliyun-oss
- mian中引入包,在multer模块中将本地存储换成oss存储
const multer = require('multer');
const MAO = require('multer-aliyun-oss');
const upload = multer({
storage: MAO({
config: {
region: '<region>',
accessKeyId: '<accessKeyId>',
accessKeySecret: '<accessKeySecret>',
bucket: '<bucket>'
}
})
});
- 创建oss存储
- 圈是bucket,线是region
- 创建AccessKey
7.添加权限,否则上传会报500
8.完成
来源:CSDN
作者:小阮的学习笔记
链接:https://blog.csdn.net/qq_44775782/article/details/104718557