Search code examples
amazon-s3jmeterput

Why am I getting headers embedded to files uploaded to S3 using JMeter?


Whenever uploading a file (json) to S3 using JMeter's HTTP Request sampler the uploaded file contains the HTTP headers at the top of the file. I am using a signed URL (with actual values):

https://something-s3bucket-something.s3.eu-west-1.amazonaws.com/afda5939-c232-d746-06f7-68790abde85b-91e962d6-4643-8091-fab8-9d0f78f35810.jsonTemp?X-Amz-Expires=18000&x-amz-security-token=somethinglongandcomplicated&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=somethingspecific&X-Amz-Date=20190627T070453Z&X-Amz-SignedHeaders=host;x-amz-security-token&X-Amz-Signature=something

HTTP Request Settings: HTTP Request Settings

Resulting json:

--Y0B3WMeM2M6xYSUHpjPUIj72y3xnO_pswRA12Oh
Content-Disposition: form-data; name="filename"; filename="500payslips.json"
Content-Type: binary/octet-stream
Content-Transfer-Encoding: binary

{
... json content ...
}
}

--Y0B3WMeM2M6xYSUHpjPUIj72y3xnO_pswRA12Oh--

I know I could add the s3 java libraries to JMeter and then code the upload but I would prefer to just simply use the HTTP Request sampler (if possible).


Solution

  • More of a workaround than a fix(?). Instead of sending the file as a multipart/form-data I just read the contents of the file into a variable and sent the content as part of the body of the request.