【发布时间】:2025-12-08 11:25:01
【问题描述】:
我对 node.js 服务还很陌生,但我遇到了 multipart/form-data 内容类型的问题。我需要一种方法来禁用特定请求的正文解析器功能。 我正在使用restify 2.6.1。 下面是一些sn-p的配置。
我的设置是:
App.js :
server.use(restify.authorizationParser());
server.use(restify.dateParser());
server.use(restify.queryParser());
server.use(restify.jsonp());
server.use(restify.bodyParser());
server.use(restifyValidator);
server.use(restify.gzipResponse());
server.use(passport.initialize());
server.use(restify.conditionalRequest());
Route.js :
app.post({path: '/test/upload/:upload_image_name', version: ver}, uploadCtr.uploadImage);
app.post( {path: '/test/upload/:upload_image_name', version:ver }, passport.authenticate('bearer',{ session: false}),uploadCtr.uploadImage);
没有 restify.bodyParser() 上传图片正在工作(但所有依赖 json 解析器的东西都失败了)
提前致谢。
【问题讨论】: