欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

七牛下载私有空间出错

程序员文章站 2022-03-19 21:06:49
...
控制器

public function qiniu()
{
$setting=C('UPLOAD_SITEIMG_QINIU');
$Upload = new \Think\Upload($setting);
// dump($Upload);
$info = $Upload->upload();//上传成功
$url = $info['file']['url'];
dump($url);
$aaa = str_replace('http://.qiniudn.com', 'http://7xkd4t.com1.z0.glb.clouddn.com/', $url);
dump($aaa);
echo Qiniu_Sign($url);
dump($info);

}

调用的方法
function Qiniu_Encode($str) // URLSafeBase64Encode
{
$find = array('+', '/');
$replace = array('-', '_');
return str_replace($find, $replace, base64_encode($str));
}
function Qiniu_Sign($url) {//$info里面的url
$setting = C ( 'UPLOAD_SITEIMG_QINIU' );
$duetime = NOW_TIME + 86400;//下载凭证有效时间
$DownloadUrl = $url . '?e=' . $duetime;
$Sign = hash_hmac ( 'sha1', $DownloadUrl, $setting ["driverConfig"] ["secrectKey"], true );
$EncodedSign = Qiniu_Encode ( $Sign );
$Token = $setting["driverConfig"]["accessKey"] . ':' . $EncodedSign;
$RealDownloadUrl = $DownloadUrl . '&token=' . $Token;
return $RealDownloadUrl;
}

浏览器访问
{
"error": "no such entry"
}

求大神指点 这是什么情况 ???

回复内容:

控制器

public function qiniu()
{
$setting=C('UPLOAD_SITEIMG_QINIU');
$Upload = new \Think\Upload($setting);
// dump($Upload);
$info = $Upload->upload();//上传成功
$url = $info['file']['url'];
dump($url);
$aaa = str_replace('http://.qiniudn.com', 'http://7xkd4t.com1.z0.glb.clouddn.com/', $url);
dump($aaa);
echo Qiniu_Sign($url);
dump($info);

}

调用的方法
function Qiniu_Encode($str) // URLSafeBase64Encode
{
$find = array('+', '/');
$replace = array('-', '_');
return str_replace($find, $replace, base64_encode($str));
}
function Qiniu_Sign($url) {//$info里面的url
$setting = C ( 'UPLOAD_SITEIMG_QINIU' );
$duetime = NOW_TIME + 86400;//下载凭证有效时间
$DownloadUrl = $url . '?e=' . $duetime;
$Sign = hash_hmac ( 'sha1', $DownloadUrl, $setting ["driverConfig"] ["secrectKey"], true );
$EncodedSign = Qiniu_Encode ( $Sign );
$Token = $setting["driverConfig"]["accessKey"] . ':' . $EncodedSign;
$RealDownloadUrl = $DownloadUrl . '&token=' . $Token;
return $RealDownloadUrl;
}

浏览器访问
{
"error": "no such entry"
}

求大神指点 这是什么情况 ???

相关标签: thinkphp php