Test file upload using HTTP PUT method

Speck picture Speck · Feb 28, 2011 · Viewed 144.9k times · Source

I've written a service using HTTP PUT method for uploading a file.

Web Browsers don't support PUT so I need a method for testing. It works great as a POST hitting it from a browser.

update: This is what worked. I tried Poster but it suffers from the same thing as using fiddler. You have to know how to build the request. curl takes care of the problem.

curl -X PUT "localhost:8080/urlstuffhere" -F "file=@filename" -b "JSESSIONID=cookievalue"

Answer

alienhard picture alienhard · Feb 28, 2011

In my opinion the best tool for such testing is curl. Its --upload-file option uploads a file by PUT, which is exactly what you want (and it can do much more, like modifying HTTP headers, in case you need it):

curl http://myservice --upload-file file.txt