Wanted to post a video file using apache benchmark - load-testing

I want to use apachebench (ab) to test file upload performance. I have read the manual and can't find a way to achieve my goal.
My goal is try to upload a file by a HTTPs Request with POST method and multipart/form-data format.
abs -n 10 -p test.txt -T "multipart/for-data;boundary=1234567890"https://myapplication.local/upload_file
I have tried this but getting error

Take a look at Benchmarking file uploads and Apache benchmark multipart/form-data
Just in case I'll copy the script here:
You'll need a text file post_data.txt with the following contents:
--1234567890
Content-Disposition: form-data; name="file"; filename="ab1_pod.jpg"
Content-Type: application/jpeg
Content-Transfer-Encoding: base64
[base64 encoding of the file]
--1234567890--
and the call:
ab -n 10 -p post_data.txt -T "multipart/form-data; boundary=1234567890" https://myapplication.local/upload_file
Have you considered using Apache JMeter? It's way more powerful and gives you the possibility to perform the multipart file upload by just specifying the file location and ticking one box:
It also provides options to define the workload model and powerful reporting
More information: JMeter Performance Testing: Upload and Download Scenarios

Related

Nitrogen - File upload directly to database

In the Nitrogen Web framework, files uploaded always end in the ./scratch/ directory when using #upload{}. From here you are supposed to manage the uploaded files, for example, by copying them to their final destination directory.
However, in case the destination is a database, is there a way of uploading these files straight to the database? Use case RIAK-KV.
You can upload a file to Riak KV using an HTTP POST request. You can see the details at in the Creating Objects documentation which shows how to do it using curl.
To send the contents of a file instead of a value, something like this should work:
curl -XPOST http://127.0.0.1:8098/types/default/buckets/scratch/keys/newkey
-d #path/to/scratch.file
-H "Content-Type: application/octet-stream"

Uploading file to rest API using JMeter

Note - I have checked BlazeMeter Tutorial which uploads doc as Body Data while I use File Upload tab.
Here is how my request looks -
On execution I get following Request -
POST https://xxx
POST data:
<actual file content, not shown here>
[no cookies]
Request Headers:
Connection: keep-alive
Content-Type: multipart/form-data
Accept-Language: en-US
Authorization: bearer <>
Accept: application/json
Content-Length: 78920
Host: test-host
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_102)
And the request fails with 400 error -
Response code: 400
Response message: Bad Request
Since I am able to carry out file upload using curl, I assume that I missed the some configuration with JMeter. Curl looks as -
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'Authorization: Bearer <>' -F upload_file=#"test.pdf" 'https://xxx'
What did I miss in JMeter file upload?
Another vote for using the Java implementation in the Advanced tab in Jmeter. My headers and body were exactly the same between postman and jmeter, but it wouldn't upload my file (got response code 415) until I changed to the Java implementation.
If you can successfully upload file via curl, why don't you just record the upload through JMeter HTTP(S) Test Script Recorder like:
curl -x http://localhost:8888 -X POST --header 'Content-Type....."
If you still need to build the request manually consider two important bits:
You need to check Use multipart/form-data for POST.
The most significant, you need to supply "Parameter Name", According to HTTP Request Sampler Manual:
For the POST and PUT method, if there is no file to send, and the name(s) of the parameter(s) are omitted, then the body is created by concatenating all the value(s) of the parameters.
Looking into curl command manual in your case the "Parameter Name" should be upload_file
So the final configuration should look like:
See Performance Testing: Upload and Download Scenarios with Apache JMeter guide for above steps described in details.
My backend server is implemented in Java and in the file upload request I had to select the Impolementation as Java!
Here is the file upload section
thank you for the JAVA implementation of HTTP! file uploads are working again for me which haven't worked since 2.13
here's my post else where:
I had same issue...thought jmeter was doing something wrong since this stuff worked for me in 2.13...hasn't worked since version 3. well..saw a post somewhere that said, using the JAVA implementation of HTTP worked. Guess what? it did work for me too!!! I've been struggling trying to dissect every part of the POST. I was doing it right all along, just needed JAVA implementation of HTTP and voila!
hope that helps!

Extract text content from Tika without specifying the file header

Is there a way to extract content from a file with a Tika server without explicitly defining the header? For example for a specific file named "file.pdf" if I do
curl -X PUT --data-binary #file.pdf localhost:9998/tika --header "Content-type: application/pdf" > file.txt
I get the extracted content in "file.txt" but if I omit the
' --header "Content-type: application/pdf" '
I get an empty "file.txt".
In general is there a way to automate the process of submitting a document to a tika server and extracting the content in txt with a single command?
Or alternatively how can I use a pipeline to redirect a possible Tika header output answer of a file to the command in the beginning of this question?
Thank you very much community!
You're calling the Tika Server wrong to get auto-detection. As detailed on the Tika Server wiki page, to have the plain text extracted from any file (including PDF) you should run Curl as:
curl -T file.pdf http://localhost:9998/tika --header "Accept: text/plain"
You need an accept header to tell Tika what format you want your result in (Plain Text or HTML for text extraction, more formats available for metadata). As long as you send the file directly with the -T option, its type will be auto-detected for you

Curl not downloading XML file as expected

When adding a URL into a web browser, I get the usual prompt to open the XML file and view it. However, when I use the same URL within a Curl batch file it only appears to download the login aspx page.
//stuff/stuff/Report.aspx?Report=All_Nodes_IP_Report&DataFormat=XML&AccountID=<UID>&Password=<password>
My batch file looks like this:
curl -L "//stuff/stuff/Report.aspx?Report=All_Nodes_IP_Report&DataFormat=XML&AccountID=<UID>&Password=<Password>" -o "local.xml" -v
pause
What am I doing wrong? There's no proxy server between me and the report URL..? The web site is https but I can't include that as the validation checker keeps moaning at me :)
why use CURL when you can use one application called MGET that i create.
Download Link:
http://bit.ly/1i1FpGE
Syntax of the command:
MGET //stuff/stuff/Report.aspx?Report=All_Nodes_IP_Report&DataFormat=XML&AccountID=<UID>&Password=<Password> local.xml
And if you want to use HTTPS do it, for best experience use HTTP

curl needs to send '\r\n' - need transformation of a working solution

I need a transformation of the following working curl command:
curl --data-binary #"data.txt" http://www.example.com/request.asp
The data.txt includes this:
foo=bar
parameter1=4711
parameter2=4712
The key is I need to send the linebreaks and they are \r\n. Its working with the file because it has the right encoding but how do I manage to get this curl command run without the file? So a 1-liner sending the parameters with the correct \r\n on end of each.
All my tests with different URL encoding, etc. didn't work. I never got the same result like with the file.
I need this information because I have serious trouble to get this post run on my Ruby on Rails App using net/http.
Thanks!
One way to solve it is to generate the binary stream with something on the fly, like the printf command, and have curl read the data from stdin:
printf 'foo=bar\r\nparameter1=4711\r\nparameter2=4712' | curl --data-binary #- http://example.com

Resources