简体   繁体   中英

Feathers js upload file using raw json in postman

How do we configure feathers js to support 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. Thanks

在此处输入图像描述

or like is there a way we can upload file without using form-data? like using raw in post-man? (edited)

For those kinds of file-uploads you need an additional middleware to handle the multipart/form-data upload - usually multer is used. 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();
    }
); 

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