0
votes

I'm sending a request to server service called path-generator which gives me a generated url and I'm uploading images to this url which moves the images to s3 bucket. I'm able to upload the file to the bucket, but it arrives as broken image (when i'm uploading the file with 'Accept: application/json, text/plain' header)

header with broken image

or as 'Content-Transfer-Encoding: binary' when not using the header

put image-no header

enter image description here

The requests:

With header:

Connection: keep-alive

Content-type: image/png

Accept: application/json, text/plain :

Content-Length: 201571

Host: {some host}

User-Agent: Apache-HttpClient/4.5.6 (Java/11.0.1)

without header:

Connection: keep-alive

Content-type: application/json

Content-Length: 221702

Host: {some host}

User-Agent: Apache-HttpClient/4.5.6 (Java/11.0.1)

I'm using the exact same flow as the client so it must be something wrong I'm doing with Jmeter

2

2 Answers

0
votes

When you tick Use multipart/form-data box JMeter doesn't use Content-Type header specified in the HTTP Header Manager, most probably this is the reason for your request failure.

Try recording the file upload request using HTTP(S) Test Script Recorder (make sure to copy the file to "bin" folder of your JMeter installation) to see if JMeter is capable of properly capture the upload request(s). If it is - you should be good to go. If not - you will have to amend JMeter configuration to 100% match request specification, check out Testing REST API File Uploads in JMeter article for example test plan.

0
votes

S3 PUT requests only need file content and no extra fields.

Do not pass parameter name and MIME type, only pass filePath correctly. If required add header Content-Type: image/jpg or video/mp4 in case it's a video. Similarly for pdf, text, etc.

Additionally, when you download the broken file and open it in notepad++ along with the actual file which was used to upload in notepad++ you can see the difference: the broken file has some extra text in it. If you remove it, it will work as expected

Also do not try this is notepad, use notepad++ only.