Skip to content

Instantly share code, notes, and snippets.

@marcustallberg
Created February 8, 2017 17:55
Show Gist options
  • Save marcustallberg/d1bae55dd408f964579f1012b2b2e659 to your computer and use it in GitHub Desktop.
Save marcustallberg/d1bae55dd408f964579f1012b2b2e659 to your computer and use it in GitHub Desktop.
Stress testing a file-upload with Apache Bench
$ab -n 10 -c 2 -p /Users/post_file.txt -T "multipart/form-data; boundary=1234567890" http://localhost/upload
post_file.txt (use CRLF line-endings):
--1234567890
Content-Disposition: form-data; filename="file.png"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
<base64 encoded file>
--1234567890--
@geosmart
Copy link

geosmart commented Nov 8, 2018

the server recieve the file , but not a valid image

byte[] imageBytes = part.getData();
FileUtils.writeByteArrayToFile(new File("d:/tmp/face/test_ab.jpg"), imageBytes);

@ekuiter
Copy link

ekuiter commented Apr 23, 2020

You need to either change Content-Transfer-Encoding to binary, or insert the binary file data instead of the base64 encoded file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment