Karate inflates binary file on a post

2019-07-26 17:29发布

问题:

I am trying to post a large (16MB) binary file as multipart but the test keeps failing. When debugging using Wireshark (see screenshot) I found out that the payload size as well as the Content-Length are more than 30MB. Any idea what is happening? Here is the code:

Given path 'post/large/file'

And multipart file 16MB_file = { read: 'file:target/myBinaryFile', filename: 'myBinaryFileName', contentType: 'application/octet-stream' }
And header Authorization = 'Basic blablabla'
When method post
Then status 200

Wireshark screenshot

回答1:

Multipart will inflate a binary file because of the Base64 encoding that happens: What does enctype='multipart/form-data' mean?

So maybe the failure is some other problem. If you still think there's a bug I'll be happy to take a look if you follow this process (and omit the large file, I'll find one): https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

A pure binary POST looks like this (second scenario): https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/upload/upload-image.feature