-1

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

enter image description here

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

Shane Rajesh
  • 67
  • 1
  • 6

1 Answers1

0

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();
    }
); 
eol
  • 23,236
  • 5
  • 46
  • 64