Reputation: 1
My current Apache JMeter test plan is basically a ForEach loop through a bunch of files. It has to set the MIME type of my file depending on the file extension.
E.g.
"fileName": "example.docx"
So now I could easily extract the fileName using the json extractor.
My question is how can I continue using this in order to set the MIME type using an if controller. (create a fileExtension variable, substring fileName -> if fileExtension == docx / if fileName.contains("docx") -> set MIME type to application/vnd.openxmlformats-officedocument.wordprocessingml.document)
Since I am new to JMeter I would appreciate any help on how to do either of those.
Thanks!
Upvotes: 0
Views: 305
Reputation: 168157
The easiest is using i.e. Apache Tika library, if you download tika-app.jar
and drop it to JMeter Classpath you will be able to detect MIME types of nearly any file from any JSR223 Test Element or __groovy() function like:
new org.apache.Tika().detect("example.docx")
Demo:
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
Upvotes: 1