poirot / client-tenderbin

此包最新版本(dev-devel)没有提供许可证信息。

TenderBin对象存储的HttpClient(SDK)。

dev-devel 2018-11-08 09:23 UTC

This package is auto-updated.

Last update: 2024-09-08 22:54:58 UTC


README

TenderBin对象存储的HttpClient(SDK)

创建SDK实例

$c = new \Poirot\TenderBinClient\Client(
    'http://172.17.0.1:8080/bin'
    , new \Poirot\ApiClient\TokenProviderSolid(
        new \Poirot\ApiClient\AccessTokenObject([
            'access_token' => '#accesstoken',
            'client_id'    => '#clientid',
            'expires_in'   => 3600,
            'scopes'       => 'scope otherscope'
        ])
    )
);

$resource = $c->getBinMeta('58eca65857077400155a1bd2');

将Bin-数据存储到存储

$r = $c->store(
    serialize( ['your_data_any_type'] )
    , 'application/php-serialized'
    , 'TenderBin Client'
    , [
        'some_tag' => 'tag value',
        'is_file'  => true, // force store as a file
    ]
);

将BinData内容加载到本地流

list($resource, $meta) = $c->loadBin('58eca65857077400155a1bd2');
header('Content-Type: '. $meta['content_type']); // read header (tags) included with bin
while ($content = fread($resource, 2048)) { // Read in 2048-byte chunks
    echo $content; // or output it somehow else.
    flush(); // force output so far
}