Search code examples
dreamfactory

Dreamfactory request internal file from file storage service


I'm writing a PHP script that requests other DF service which is a FileStorage. When I request the folder containing the file the response is correct, but when I want to request directly a file(json or xml) there is an error:

DF LOGS:

local.ERROR: Type error: Argument 1 passed to DreamFactory\Core\Utility\ResponseFactory::sendScriptResponse() must implement interface DreamFactory\Core\Contracts\ServiceResponseInterface, instance of Symfony\Component\HttpFoundation\StreamedResponse given, called in D:\socle_64\dreamfactory-2.12.0\apps\dreamfactory\htdocs\vendor\dreamfactory\df-script\src\Components\BaseEngineAdapter.php

PHP Script looks like this:

$platform['api']->get->__invoke('service/file');

When I pass only the path to folder containing the file it works well. Same request via Postman or outside my DF service works well.

Thanks

PS : Sorry for my english.


Solution

  • Well I found the issue solution:

    $result = $platform['api']->get->__invoke('service/file.txt?include_properties=true&content=true');
    

    => return the file content base64 encoded

    $file = base64_decode($response['content'], true);