alexfernandez / loadtest

Runs a load test on the selected URL. Fast and easy to use. Can be integrated in your own workflow using the API.
MIT License
2.57k stars 209 forks source link

[Question][form-field with file as payload]Trying to mimic curl -F "file=@video.mp4" #194

Closed bmsan closed 1 year ago

bmsan commented 3 years ago

Hello,

I have a curl command that works curl -F "file=@vid.mp4" https://servername/api/upload

I am not sure how to translate it into loadtest: I have tried:

loadtest -n 1 -c 1 -m POST -p vid.mp4  https://servername/api/upload
or
loadtest -n 1 -c 1 -m POST -p vid.mp4 -T "multipart/form-data" https://servername/api/upload

But it results in an error. INFO 400: 1 errors

From curl's man:

-F
 For HTTP protocol family, this lets curl emulate a filled-in form in which a user has pressed the submit button. 
This causes curl to POST data using the Content-Type multipart/form-data according to RFC 2388.

Example: send an image to an HTTP server, where 'profile' is the name of the form-field to which 
the file portrait.jpg will be the input:
 curl -F profile=@portrait.jpg https://example.com/upload.cgi
alexfernandez commented 3 years ago

Sorry for the delay! You need to send the content-type with -T:

loadtest -n 1 -c 1 -m POST -p vid.mp4 -T "video/mp4"

Does this work? :thinking:

alexfernandez commented 1 year ago

Closing, please reopen if needed.