HTTP Client: How to create pdf when in HTTP body as JSON encapsulated
Hi,
I have the situation that the HTTP client receives a PDF encapsulated by JSON in the HTTP body.
{
"mimetype": "application/pdf", "base64String": “JVBERi0xLjQKJaqrrK0KMSAwIG9iago8PAovQ3JlYXRvciAoSU5GSU5JQ0EpCi9Qcm9kdWNlciAoSU5GSU5JQ0EpCi9DcmVhdGlvbkRhdGUgKEQ6MjAyNDA5MDkxMjE5MzdaKQo+PgplbmRvYmoKMiAwIG9iago8PAogIC9OIDMKICAvTGVuZ3RoIDMgMCBSCiAgL0ZpbHRlciAvRmxhdGVEZWNvZGUKPj4Kc3RyZWFtCnic7ZlnUFRZFoDve50TDd1Nk6HJSaKEBiTnJDmKCnQ3mRaaDCqKDI7ACC==”
}
The recommanded way to redirect it to a file >> output.pdf does not work becuase a JSON file is stored.
Honestly I didn't find any solution how to solve the issue with response handler and JavaScript.
Is there an example how the base64String will be decoded and store as a pdf in any folder.
Thanks,
Markus
请先登录再写评论。
```
GET <URL>> {%const fs = require('fs');const pdfData = response.body.base64String;const buffer = Buffer.from(pdfData, 'base64');fs.writeFileSync('output.pdf', buffer);%}
```
Thanks Bond,
but it seems to be node.js.
So far as I got it to work it looks like this:
But I had to copy
atoband further it does not work becauseBlobandFileare unresolved types.ArrayBufferandUint8Arrayare coming from lib.es5.d.ts which seems to be shipped by Intellij.I assume I do not have enough JavaScript expierence.
Please go to Settings | Languages & Frameworks | JavaScript | Libraries, click Download, choose '@types/worker-plugin', and click 'Download and install'. Does it help?