|
想用七牛储存上传的文件,需要生成一个token ,用了官方的生成sdk的类 里边有命名空间 在控制器里无法载入 该怎么办 这个类里面的代码还有用到命名空间的贴出部分代码:
<?php
namespace Qiniu;
use Qiniu;
use Qiniu\Zone;
final class Auth
。。。。。
public function uploadToken(
$bucket,
$key = null,
$expires = 3600,
$policy = null,
$strictPolicy = true
Zone $zone = null //这里用到了zone
) {
$deadline = time() + $expires;
$scope = $bucket;
if ($key !== null) {
$scope .= ':' . $key;
}
$args = array();
$args = self::copyPolicy($args, $policy, $strictPolicy);
$args['scope'] = $scope;
$args['deadline'] = $deadline;
if ($zone === null) {
$zone = new Zone(); //这里用到了zone
}
list($upHosts, $err) = $zone->getUpHosts($this->accessKey, $bucket); //这里用到了zone
if ($err === null) {
$args['upHosts'] = $upHosts;
}
|
|