itfarmstorage/itfarmstorage

itfarm cloud storage sdk

v0.2.2 2021-02-26 02:15 UTC

This package is auto-updated.

Last update: 2022-07-17 08:45:40 UTC


README

/**
 * 存储类型  1-七牛云    2-VM   3-虚拟机
 */
    const STORAGE_TYPE_QINIU = 'qiniu';
    const STORAGE_TYPE_VM = 'vm';
    const STORAGE_TYPE_CEPH = 'ceph';

获取cephToken

namespace App\Http\Middleware;

use ItFarmStorage\ItFarmStorage\Constant;
use ItFarmStorage\ItFarmStorage\StorageClient;
/**
 * @Bean()
 */
class ControllerMiddleware implements MiddlewareInterface
{
    public function getCephToken()
    {
        //实例化参数
        $uploadHost = 'https://uploadhost.oneitfarm.com/';
        $accessHost = 'https://accesshost.oneitfarm.com/';
        $returnBody = '{"key":"$(key)","hash":"$(etag)","fsize":$(fsize),"bucket":"$(bucket)","name":"$(fname)","ext":"$(ext)","mime_type":"$(mimeType)","image_info":$(imageInfo),"video_duration":$(avinfo.video.duration),"audio_duration":$(avinfo.audio.duration),"persistent_id":$(persistentId)}';
        $policy = ['returnBody' => $returnBody];
        $access_key = 'XXXXXXXXXXXXXXXXXXXXX';
        $secret_key = 'XXXXXXXXXXXXXXXXXXXXX';

        //获取云客户端实例
        $StorageClient = StorageClient::getInstance(
            Constant::STORAGE_TYPE_CEPH,
            $access_key,
            $secret_key
        );
        //获取token
        $data = $StorageClient->uploadToken(
            $accessHost,
            $uploadHost,
            $disk['bucket'],
            null,
            3600,
            $policy
        );
        return $data;
    }
}