Reputation: 4675
I am using Angular in the front and Nodejs + Express 4 at backend. When I'm trying to upload a file using simple html form, the request contains:
Content-Type: image/jpeg
whereas plugings like busboy, connect-busboy etc. require Content-Type to be multipart/form-data and hence there is nothing in req.files
What I'm missing here?
Upvotes: 0
Views: 299
Reputation: 1091
It might not relate to your question. However, let me leave some workaround I did when I had the same issue like you. I totally agree that it could be a bit tricky to send files over the wire from Angular to Express.
What I came up with was compiling files into base64 string. And decode them when the backend grabs the base64 string data. This way could easily avoid the issue you mentioned on your post.
Secondly, if your app is in microservice architecture, and if you are willing to do so, use Amazon S3 or Cloudinary to store your data. And you will just save the link url for the files in your database. By doing so, you can reduce significant amount of request to your backend, and you can deal with the data easily.
Hope these solutions work for you!
Upvotes: 1