我正在与Multer建立文件上传路径,并且工作正常。但是,我无法弄清楚如何获取上载的音频文件元数据,例如专辑,艺术家,长度等。是否可以通过multer获取此类元数据?是否有提供上传元数据的替代方法?
路线:
const express = require('express');
const router = express.Router();
const multer = require('multer');
const uploadDest = 'public/media/';
const allowedMimeTypes = ['audio/wav', 'audio/mp3'];
const filter = function (req, file, cb) {
if (!allowedMimeTypes.includes(file.mimetype.toLowerCase())) {
cb(null, false);
}
cb(null, true);
};
var upload = multer({
dest: uploadDest,
fileFilter: filter,
});
// '/upload'
router.post('/', upload.array('media', 12), function (req, res, next) {
console.log('file-upload');
});
module.exports = router;