RawFileBodyPart currently only accepts a file from the resources folder.
How do I read a file outside of the resources folder?
Alternatively, how do I convert a byte array into a RawFileBodyPart since ByteArrayBodyPart seems to be functionally different and will cause a failure where RawFileBodyPart would have worked
Works:

Doesn’t work, bytes are read and sent but API doesn’t accept it as raw file:

RawFileBodyPart currently only accepts a file from the resources folder.
It shouldn’t. It should fallback to using a relative location, then an absolute one.
Do you have any data to back your statement? Typically, as stated in this group’s terms:
- Make sure you’re using an up-to-date Gatling version
- Provide a Short, Self Contained, Correct (Compilable), Example (see http://sscce.org/)
.bodyPart(RawFileBodyPart(“file”, session => “data.txt”))
Why do you pass a function that returns a static value?
.bodyPart(RawFileBodyPart(“file”, “data.txt”))
Doesn’t work
.bodyPart(ByteArrayBodyPart(session => {
val dir = new File(“/data”)
val file = new File(dir, “data.txt”)
Files.readAllBytes(Paths.get(file.getAbsolutePath))
}))
No idea what doesn’t work as you don’t provide any detail, but using this would be way more simple:
I see, my bad as I couldn’t find this documented anywhere, and I assumed it only read from the resources directory.
This seems to work. Thanks!