【发布时间】:2018-05-24 12:43:25
【问题描述】:
我正在尝试通过邮递员使用form-data 将图像上传到cloudinary
我也在使用名为 multer-storage-cloudinary 的 npm 包。但是,我遇到了麻烦。这是我的代码:
cloudinary.config({
cloud_name: 'ax850',
api_key: config.CLOUDINARY_API_KEY,
api_secret:config.CLOUDINARY_API_SECRET_KEY
});
let storage = cloudinaryStorage({
cloudinary: cloudinary,
folder: '/Memory',
allowedFormats: ['jpg', 'png'],
filename: function (req, file, cb) {
cb(undefined, 'testing');
}
});
let parser = multer({ storage: storage });
app.post('/upload', parser.array('images', 10), function (req, res) {
console.log(req.files);
});
没有错误,它只是在崩溃前几乎冻结了。我的云端有一个/Memory 文件夹。
有什么想法吗?
【问题讨论】:
-
您需要 multer 和 cloudinary 包,并且在定义文件夹时尝试不使用 /,因此它将是 `folder: "Memory",
标签: node.js cloudinary