Uploading File using Multipart request causes extra info in the file to be sent

Hi there, recently I was trying to test uploading a file using the post call below:

.exec(
http(“post”)
.post("/${firmName}/e/eng/${SEUuid}/api/upload?
resumableChunkNumber=1&
resumableChunkSize=1048576&
resumableCurrentChunkSize=1&
resumableTotalSize=1&
resumableType=text%2Fplain&
resumableIdentifier=1-atxt-1437681971651&
resumableFilename=a.txt&
resumableRelativePath=a.txt&
resumableTotalChunks=1&
type=document")
.headers(TestSettings.seGeneralHeader)
.bodyPart(ELFileBodyPart(“a.txt”, “${tmpFilePath}”))
.check(bodyString.saveAs(“body”))
.check(jsonPath("$…errors").notExists)

)

The file should only have the single letter a in it, however when I check it after it’s been posted, it produces the following.

--2eLeT-QifDO6ozBK8C0Kf925DxIFUs
Content-Disposition: form-data; name="a.txt"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

a
--2eLeT-QifDO6ozBK8C0Kf925DxIFUs--


I tried to use the the additional options of bodyPart as stated in the documentation, but I couldn’t get the additional information to go away.

How are you receiving the file? What is your server technology stack?

Unfortuantely I’m currently black box testing so I don’t have much on how exactly the server technology works. I was hoping for help on specifically manipulating
the additional configure options with the bodyPart of the post call to get rid of the extra text. Is that asking for too much in this situation?

The problem may be the black box, and not Gatling. It looks like the server is not properly interpreting what it receives, it is just dumping it to a file. That’s why I asked about the server. Someone who is more versed in multi-part MIME encoding would have to comment.

I’d say your file upload feature is not implemented as a form upload (ie multipart) but the file is directly the body.
Use a Body instead of a BodyPart.

.exec(
http(“post”)
.post("/${firmName}/e/eng/${SEUuid}/api/upload?
resumableChunkNumber=1&
resumableChunkSize=1048576&
resumableCurrentChunkSize=1&
resumableTotalSize=1&
resumableType=text%2Fplain&
resumableIdentifier=1-atxt-1437681971651&
resumableFilename=a.txt&
resumableRelativePath=a.txt&
resumableTotalChunks=1&
type=document")
.headers(TestSettings.seGeneralHeader)

.formUpload(“a.txt”, “${tmpFilePath}”)
.check(jsonPath("$…errors").notExists)

)

Is this correct? I tried to do this but my problem still remains.

I don’t think so.
formUpload is just a convenient alias/shortcut for what you’ve been doing so far with BodyPart.
It seems your server interpret the whole request HTTP body as the uploaded file.
As I said, try using Body instead of BodyPart.