I'm looking to implement an API similar to Imgur's upload feature: http://api.imgur.com/resources_anon#upload. In other words, a user should be able to upload an image by POSTing to /upload
with an image file without using a form, ie through AJAX without setting the Content-Type
header (just like Imgur). However, the only example I can find is the following: https://github.com/visionmedia/express/blob/master/examples/multipart/app.js
Question: How should I implement such an API? My concern is that Express won't interpret the command as multipart/form-data
.
Assuming the client sets the upload request's Content-Type
properly (which it will if the form used for the upload has the correct enctype
attribute) and you use express.bodyParser()
, express will handle everything correctly.