Dreamfactory 从文件存储服务请求内部文件
Dreamfactory request internal file from file storage service
我正在编写一个 PHP 脚本来请求其他 DF 服务,即 FileStorage。
当我请求包含文件的文件夹时,响应是正确的,但是当
我想直接请求一个文件(json或xml)出现错误:
DF 日志:
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 脚本如下所示:
$platform['api']->get->__invoke('service/file');
当我只传递包含文件的文件夹的路径时,效果很好。
通过 Postman 或我的 DF 服务之外的相同请求效果很好。
谢谢
PS:对不起我的英语。
好吧,我找到了问题解决方案:
$result = $platform['api']->get->__invoke('service/file.txt?include_properties=true&content=true');
=> return base64编码的文件内容
$file = base64_decode($response['content'], true);
我正在编写一个 PHP 脚本来请求其他 DF 服务,即 FileStorage。 当我请求包含文件的文件夹时,响应是正确的,但是当 我想直接请求一个文件(json或xml)出现错误:
DF 日志:
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 脚本如下所示:
$platform['api']->get->__invoke('service/file');
当我只传递包含文件的文件夹的路径时,效果很好。 通过 Postman 或我的 DF 服务之外的相同请求效果很好。
谢谢
PS:对不起我的英语。
好吧,我找到了问题解决方案:
$result = $platform['api']->get->__invoke('service/file.txt?include_properties=true&content=true');
=> return base64编码的文件内容
$file = base64_decode($response['content'], true);