Node.js 如何在服务器批准后才接受multer中的上载?
我正在编写一个应用程序,它使用electron、node和multer接受从客户端到服务器的上传。 我想做的是只允许上传后,服务器已接受它。也许是某种提示。我将如何在JS中进行 虽然我提到了穆特,但我想它不会在这件事中起到很大作用。Rn,我的上传功能是这样运行的Node.js 如何在服务器批准后才接受multer中的上载?,node.js,electron,multer,Node.js,Electron,Multer,我正在编写一个应用程序,它使用electron、node和multer接受从客户端到服务器的上传。 我想做的是只允许上传后,服务器已接受它。也许是某种提示。我将如何在JS中进行 虽然我提到了穆特,但我想它不会在这件事中起到很大作用。Rn,我的上传功能是这样运行的 var upload = multer({ storage: storage, }) app.post('/uploadfile', upload.single('single'), (req, res, next) => {
var upload = multer({ storage: storage, })
app.post('/uploadfile', upload.single('single'), (req, res, next) => {
const file = req.file
if (!file) {
const error = new Error('Please upload a file')
error.httpStatusCode = 400
return next(error)
}
res.send(file)
})
当请求到来时,我想我必须使用其他提示验证的东西,而不是运行“upload.single”,然后运行实际的上传功能。但我很无知。非常感谢您的帮助。将上传过程与身份验证分开。对用户进行身份验证,然后允许用户上载文件。将上载过程与身份验证分开。对用户进行身份验证,然后允许用户上载文件。