fs.readfilesync(...) 给出内部服务器错误 500

时间:2021-01-10 08:51:47

标签: node.js reactjs mongodb express mongoose

我想在 MongoDB 中存储一个 PDF 文件并使用 reactexpress 检索它。但是在我使用 #app 方法的 express 文件中,它抛出 500 fs.readfilesync(...)

反应文件:

(Internal Server Error)

猫鼬模式:

const fd = new FormData();
fd.append("file", e.target.files[0]);
fd.set("data", e.target.title.value);

axios
  .post(url, fd)
  .then(...)
  .catch(...);

快递文件:

const mongoose = require('mongoose');

const fileSchema = new mongoose.Schema({
    title: String,
    pdf: {
        data: Buffer,
        contentType: String
    }
})
module.exports = new mongoose.model('File', fileSchema);

0 个答案:

没有答案