Home > Backend Development > PHP Tutorial > 七牛下载私有空间出错

七牛下载私有空间出错

WBOY
Release: 2016-06-06 20:30:10
Original
1166 people have browsed it

控制器

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);

<code>}
</code>
Copy after login
Copy after login

调用的方法
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);

<code>}
</code>
Copy after login
Copy after login

调用的方法
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"
}

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template