Binary file returned by server API

Is it possible to call a remote api from server side and capture the binary file that is returned? I can’t seem to find how to save that file to a server folder.

Thanks!

–Ken

Not sure if it possible yet but maybe if we thread it like a file upload, could be easy to do.

Maybe @patrick can investigate.

What API are you using Ken? Got a test case?

Thanks George,

This one is the DocRaptor api for creating pdf’s.

Here is what the api output looks like from a server api action:

{"api2":{"status":200,"headers":{"0":"HTTP\/1.1 200 OK","Cache-Control":"private","Content-Disposition":"attachment; filename=\"doc-113581866.pdf\"","Content-Transfer-Encoding":"binary","Content-Type":"application\/pdf","Date":"Sat, 16 Nov 2019 15:33:41 GMT","ETag":"W\/\"659bfa7f1a786c561363fae425d785ed\"","Server":"nginx","Set-Cookie":["_doc_raptor_session=NmVuQkJLZVFtK25SclJXeEtSK3YxaXhHTmpRSzZwS0JEQ1Rwcm81a25FTThFYXJyb0JKb0JIeHRkakRjU2pxUHVncVhoekg1OG1wbEo1bG5mTzlwZVR6RkpNdGZFUnhPeHpnZTF5aVRJZGtLWS9lT2w3bDQ4VnpWVXFkS1Zjc0p0alVQR3hQdFMrMWFOWG5CMmJKQkRGODNqME5TZGlua3lMOFhHaXYxSHNUTGpvUE1rWU8xZ25rN0hxb2xYK0ZiTGdZQ1Y5cDMvY2ZqZjVhU2thZjFFdy9GZHlHQWhrTWNVM2dEcnhZdVdkbDFPaDhpN3FTUHhwVG1vWVZIV2h1VEZWdDlMcGlScTEwUmsvYzYyRUF4aDlXdzFFKzdHS25vUlg1d1BjaGRoN0dPc2lPNm83cVJKSytXS2w4TFM1bVUtLXVqajFoMUIwT0JZSmhZNFV2eW1mdHc9PQ%3D%3D--4e896d1eb25e8b68c95e1f885c4cbe0842b511d8; path=\/; secure; HttpOnly","eb_tracking_id=16efa723-b41e-4c0f-99c0-2c0d56855446; path=\/; expires=Fri, 11 Nov 2039 15:33:41 -0000"],"X-Content-Type-Options":"nosniff","X-DocRaptor-Num-Pages":"1","X-Frame-Options":"SAMEORIGIN","X-Request-Id":"e80b3e71-55a9-4e3a-869f-21ea25f9f637","X-Runtime":"4.690873","X-XSS-Protection":"1; mode=block","transfer-encoding":"chunked","Connection":"keep-alive"},"data":}}

They have a free trial if you decide to pursue this, or DM me if you want my api key to use a paid account.

Thanks for looking into it!

–Ken

To revive this old but related post…Is there now a way to receive a binary post that comes over in the body of the request?

If I create my own php file, I can use this to retrieve and save the file locally on the server:

$entityBody = file_get_contents('php://input');

file_put_contents ( '/path_to_uploads/fileupload.png', $entityBody );

Before I create a custom file, just want to make sure there is currently no way to receive this file in Server Connect… @patrick ?

I don’t think Wappler supports anything other than JSON as API responses at the moment - on all server types. I’m not sure if its in the pipeline either.

Thanks for the confirmation Sid…I’ve gone ahead with the custom approach and it’s working fine.

1 Like