Testing file uploading with curl
Today I spent some time adding user avatars to a NodeJS application. I’m using Formidable and Express to do it, but it’s finicky enough that I want to get the endpoint working before I start doing any forms.
If you want to upload an image with curl you can use
curl -d @avatar.jpg "http://localhost:3000/avatar/2"
but if you want to add some ancillary data, you’ll need something like;
curl -F "firstname.lastname@example.org;type=image/jpg"-F "id=2" "http://localhost:3000/avatar/2"