[英]Feathers js upload file using raw json in postman
How do we configure feathers js to support form-data?我们如何配置feathers js来支持form-data? .
. Basically my current implementation right now supports raw json, but I have a feature where I have to upload file to amazon bucket and the only way to upload the file like using postman is to support form-data.
基本上我目前的实现现在支持原始 json,但我有一个功能,我必须将文件上传到亚马逊存储桶,并且像使用 postman 一样上传文件的唯一方法是支持表单数据。 Thanks
谢谢
or like is there a way we can upload file without using form-data?或者像有没有一种方法可以在不使用表单数据的情况下上传文件? like using raw in post-man?
喜欢在邮递员中使用 raw 吗? (edited)
(已编辑)
For those kinds of file-uploads you need an additional middleware to handle the multipart/form-data
upload - usually multer is used.对于这些类型的文件上传,您需要一个额外的中间件来处理
multipart/form-data
上传 - 通常使用multer 。 Here's some sample code that should help you get started:以下是一些可以帮助您入门的示例代码:
const multer = require('multer');
const fileUploadHandler = multer();
// Upload Service with multipart support
app.use('/photos',
// you can define different storage options, the default is to keep the uploaded data in memory
fileUploadHandler.single('filename'),
function(req,res,next){
// the uploaded file is accessible now under req.file
next();
}
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.