简体   繁体   中英

Multer Uploaded Audio File Metadata

I am setting up a file upload route with Multer and it's working fine. However, I'm unable to figure out how to get the uploaded audio file metadata such as album, artist, length, etc. Is it possible to get such metadata with multer? Is there an alternative that provides upload metadata?

Route:

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;

在 multer 上传完成后,我最终使用音乐元数据来解析文件的元数据。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM