使用语言PHP
$bucket='XX';
$AK='XXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$SK='XXXXXXXXXXXXXXXXXXXXXXXXXXXX';
functionbase64_urlSafeEncode($data)
{
$find= array('+','/');
$replace= array('-','_');
returnstr_replace($find,$replace,base64_encode($data));
}
$putPolicy=[
'insertOnly'=>1,//已新增模式增加
'scope'=>$bucket,//空间名称
'deadline'=>time()+3600,//token有效期
];
$jsonData=json_encode($putPolicy);
$encodedPutPolicy=base64_urlSafeEncode($jsonData);
$sign=hash_hmac('sha1',$encodedPutPolicy,$SK, true);
$encodedSign=base64_urlSafeEncode($sign);
$uploadToken=$AK.':'.$encodedSign.':'.$encodedPutPolicy;
var_dump($uploadToken);