Skip to content

Commit

Permalink
Merge pull request #30 from django-wong/master
Browse files Browse the repository at this point in the history
增加对私有库的配置,修复avinfo等
  • Loading branch information
zgldh authored May 12, 2017
2 parents ac1da4d + 84f273f commit 6ff9b0e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'secret_key'=> '', //SecretKey
'bucket' => '', //Bucket名字
'notify_url'=> '', //持久化处理回调地址
'access' => 'public' //空间访问控制 public 或 private
],
],

Expand Down
15 changes: 10 additions & 5 deletions src/QiniuAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class QiniuAdapter extends AbstractAdapter
private $bucket = null;
private $domains = null;
private $notify_url = null; //持久化处理后的回调地址
private $access = null;

private $auth = null;
private $upload_manager = null;
Expand All @@ -35,7 +36,7 @@ class QiniuAdapter extends AbstractAdapter

private $lastQetag = null;

public function __construct($access_key, $secret_key, $bucket, $domains, $notify_url = null)
public function __construct($access_key, $secret_key, $bucket, $domains, $notify_url = null, $access = 'public')
{
$this->access_key = $access_key;
$this->secret_key = $secret_key;
Expand All @@ -46,6 +47,7 @@ public function __construct($access_key, $secret_key, $bucket, $domains, $notify
$this->setDomainPrefix('https://' . $this->domains['https'], 'https');
$this->setDomainPrefix('http://' . $this->domains['custom'], 'custom');
$this->notify_url = $notify_url;
$this->access = $access;
}

/**
Expand Down Expand Up @@ -97,7 +99,10 @@ private function getBucketManager()
private function getOperation()
{
if ($this->operation == null) {
$this->operation = new Operation($this->domains['default']);
$this->operation = new Operation(
$this->domains['default'],
$this->access === 'public' ? null : $this->getAuth()
);
}

return $this->operation;
Expand Down Expand Up @@ -560,11 +565,11 @@ public function privateDownloadUrl($path, $settings = 'default')
* @param bool $force
* @return bool
*/
public function persistentFop($path = null, $fops = null, $pipline = null, $force = false)
public function persistentFop($path = null, $fops = null, $pipline = null, $force = false, $notify_url = null)
{
$auth = $this->getAuth();

$pfop = New PersistentFop($auth, $this->bucket, $pipline, $this->notify_url, $force);
$pfop = New PersistentFop($auth, $this->bucket, $pipline, is_null($notify_url) ? $this->notify_url : $notify_url, $force);

list($id, $error) = $pfop->execute($path, $fops);

Expand Down Expand Up @@ -596,7 +601,7 @@ public function avInfo($path = null)
{
$operation = $this->getOperation();

list($ret, $error) = $operation->execute($path, 'avInfo');
list($ret, $error) = $operation->execute($path, 'avinfo');

if ($error !== null) {
$this->logQiniuError($error);
Expand Down
3 changes: 2 additions & 1 deletion src/QiniuFilesystemServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function ($app, $config) {
$config['secret_key'],
$config['bucket'],
$domains,
$config['notify_url'] ? $config['notify_url'] : null
$config['notify_url'] ? $config['notify_url'] : null,
$config['access'] ? $config['access'] : null
);
$file_system = new Filesystem($qiniu_adapter);
$file_system->addPlugin(new PrivateDownloadUrl());
Expand Down
10 changes: 8 additions & 2 deletions src/QiniuStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ public function deleteDirectory($key)
/**
* 获取上传Token
* @param $key
* @param $expires
* @param $policy
* @param $strictPolicy
* @return bool
*/
public function uploadToken($key = null, $expires = 3600, $policy = null, $strictPolicy = true)
Expand Down Expand Up @@ -236,11 +239,14 @@ public function privateImagePreviewUrl($key, $opts)
* 执行持久化数据处理
* @param $key
* @param $opts
* @param $pipline
* @param $force
* @param $notify_url
* @return mixed
*/
public function persistentFop($key, $opts)
public function persistentFop($key, $opts, $pipline = null, $force = false, $notify_url = null)
{
return $this->storage->getDriver()->persistentFop($key, $opts);
return $this->storage->getDriver()->persistentFop($key, $opts, $pipline, $force, $notify_url);
}

/**
Expand Down

0 comments on commit 6ff9b0e

Please sign in to comment.