2

I am trying to mock the request to upload a zip file through 'POST' method using Wiremock. But I could not find the required property for that. Following is my mocked request which needs to be sent. How can I save this file to the _file directory through POST request?

"request":
 {
   "url": "/order/uploadFile",
   "method": "POST",
   "headers": {
     "token": {
       "equalTo": "0000000"
     },
 "Content-Type":{
   "equalTo": "multipart/form-data"
 }
   },
 "bodyPatterns": [{
     "equalToJson": "{\"sampleFile\":\"Sample_file.zip\"}"}]
} ....```

Here is the postman request. [![request-postman][1]][1]


[![enter image description here][1]][1]


[1]: https://i.stack.imgur.com/CQaSj.png
SMash
  • 345
  • 2
  • 7
  • 23

1 Answers1

2

In short: you can't save anything to the __files directory using the out-of-the-box standalone WireMock from withing a mapping rule. This functionality requires a custom extension that needs to do the saving for you.

That said, it is possible, according to this Stack Overflow answer to store a file in __files using a PUT on /__admin/files/[your desired filename]. This will then create a new file under the __files. It appears to be undocumented and as such may not feature in future versions. Sub-folders seem to go unsupported when I tried it.

A. Kootstra
  • 6,827
  • 3
  • 20
  • 43