What would be the best way to parameterize the contentType and dispositionType in the following:
.bodyPart(RawFileBodyPart(session => getDataFilePathAsString(session(“file-relative-path”).as[String]).mkString)
.charset(“utf-8”)
.contentType(“application/pdf”)
.dispositionType(“form-data; name=“upload”; filename=“sample.pdf””))
The contentType value and the filename value in the dispositionType string are being fed in through a csv feeder like the following:
file-relative-path,file-name,content-type
upload/sample.pdf,sample.pdf,application/pdf
upload/small.txt,small.txt,plain/text
upload/medium.txt,medium.txt,plain/text
upload/large.txt,large.txt,plain/text
Thanks,
Steve
Excilys
2
You can use Gatling EL to inject the file name in the dispositionType.
But contentType is currently a simple String.
I just implemented it for Gatling 2.1: https://github.com/gatling/gatling/issues/2392
In the mean time, if you are not ready to upgrade, you should be able to use:
.header( “Content-type”, “${content-type}” )
Excilys
4
No, because what Steven want is to set the part content-type, not the request content-type (which is multipart).
Missed that. Glad you didn’t.
Excilys
6
No pro. Thanks a lot for all your comments on this mailing list!
Hey Guys,
I changed to 2.1.0-SNAPSHOT and am able to parameterize contentType now but dispositionType still looks like a simple String:
def dispositionType(dispositionType: String) = copy(attributes = attributes.copy(dispositionType = Some(dispositionType)))
I tried by doing something like this:
.bodyPart(RawFileBodyPart(getDataFilePathAsString(“upload/sample.pdf”).mkString)
.charset(“utf-8”)
.contentType("${content-type}")
.dispositionType("${disposition-type}"))
but when I run it I am seeing this as the disposition type:
FilePart: name=null contentType=application/pdf dispositionType=${disposition-type} charset=UTF-8 transferEncoding=binary contentId=null filename=sample.pdf file=/Users/szaluk/code/qa/performance/src/test/resources/data/upload/sample.pdf
It seems like the substitutions are not being made. Am I doing this incorrectly?
Thanks!
–Steve
Excilys
8
Not a problem. Hoping to bank up some good will for when I have questions…