<?php


namespace App\Http\Controllers\Api;



class UploadConfigController extends Controller
{
    //获取oss配置
    public function config(){
        $config = config("filesystems.disks.oss");

        $policy=array(
            "expiration"=>date("Y-m-d\\TH:i:s",(time()+60)).".000Z",//"2020-01-01T12:00:00.000Z"
            "conditions"=>array(
                array(
                    "content-length-range", 0, 1048576000
                )
            )
        );
        $policyText=json_encode($policy);
        $policyBase64=base64_encode($policyText);
        $bytes=hash_hmac("sha1",$policyBase64,$config['secret_key'],true);
        $signature=base64_encode($bytes);
        $res['policy']=$policyBase64;
        $res['signature']=$signature;
        $res['OSSAccessKeyId']=$config['access_key'];
        $res['domain']="https://".$config['bucket'].'.'.$config['endpoint'];
        $res['folder']="chengluApp";
        return response()->json($res);
    }
}
