alexfernandez/loadtest

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

bmsan opened this issue · 2 comments

bmsan commented

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

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? 🤔

Closing, please reopen if needed.