Open ayevee opened 3 years ago
I was able to use Wiremock for serving static binary files, example of the mapping JSON for serving the file __files/download/document.pdf
:
{
"id" : "20221014-1032-aaaa-aaaa-aaaaaaaaaaaa",
"uuid" : "20221014-1032-aaaa-aaaa-aaaaaaaaaaaa",
"request" : {
"method" : "GET",
"url" : "/download/pdf"
},
"response" : {
"status" : 200,
"bodyFileName" : "download/document.pdf",
"headers" : {
"Content-Type" : "application/pdf"
}
}
}
You can add Content-Length
response header for static files with known size as well.
The handlebars "{{" exception can be avoided by disabling global templating. You have to enable templating only for particualr mocks/mappings.
Seems to be a use-case for https://github.com/wiremock/wiremock/issues/2145 (or not, this seems to demand extra logic to define whole response in the pattern)
I need to mock an service which has one of the endpoint serving zip files.
Unfortunately bodyFileName cannot be used for this purpose as it expects file to be a UTF8 string, not binary data, the downloaded archive is corrupt.
Using base64Body is not a convenient option in my case as well as:
Could you please add an option to send binary file from disk in stub responses (e.g. something like binaryBodyFileName).
I've noticed a couple of issues while trying to make it work: