JMeter file upload using HTTP method doesn't work
The idea is to create a sampler in JMeter that will upload the file using the HTTP PUT method. I am trying to follow the official documentation to specify the entire content object as a file with no parameter name.
- What should happen: the file is uploaded and the server returns 201: created
- What actually happens:
java.lang.NullPointerException: charsetName
at java.lang.String.<init>(Unknown Source)
at java.lang.String.<init>(Unknown Source)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sendPutData(HTTPHC4Impl.java:1067)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:274)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1054)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1043)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:416)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:271)
at java.lang.Thread.run(Unknown Source)
This seems to indicate that JMeter is having a problem filling in the request body. I can get rid of this error by specifying a parameter with the request, but I want the whole body to be photodata. Here's the CURL line I want to execute:
curl -u testuser:testpass "http://localhost:8080/photo" -T photo.jpg -H "content-type:image/jpeg"
I tried setting the content encoding to UTF-8 as I saw in one post, but didn't change anything.
I am running Java 1.7.0 on Windows 7 x64. Nothing interesting is generated in the jmeter.log and wireshark tells me that JMeter is not sending a request.
Any ideas? Thanks in advance.
source to share
It turns out it was a bug that the good people at JMeter were able to fix very quickly: https://issues.apache.org/bugzilla/show_bug.cgi?id=52897
Using a nightly build solved my problem, and by now it has probably made it into release.
source to share
Use a Raw HTTP Request to accomplish this. You can specify headers in data requests and also specify the file containing the PUT body for convenience.
Some details can be found here
source to share
I'm having problems downloading the images and find answers here fooobar.com/questions/1891616 / ... . After making the suggested changes, I had to rewrite the transaction and make the changes and I was able to upload the files successfully.
Hope it helps.
source to share