Skip to content

Commit

Permalink
Migrate getDriver to getAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
zgldh committed Feb 17, 2022
1 parent d026896 commit b4838a3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 53 deletions.
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,42 +102,42 @@
$disk->url('a.png'); //返回文件的URL
$disk->url(['path' => 'a.png', 'domainType' => 'default']); //返回文件的URL

$disk->getDriver()->uploadToken(); //获取上传Token
$disk->getDriver()->uploadToken('file.jpg'); //获取上传Token
$disk->getAdapter()->uploadToken(); //获取上传Token
$disk->getAdapter()->uploadToken('file.jpg'); //获取上传Token

$disk->getDriver()->withUploadToken($token); // 使用自定义的 uploadToken 进行上传,
$disk->getAdapter()->withUploadToken($token); // 使用自定义的 uploadToken 进行上传,
$disk->put('file.jpg',$content); // 则本次的 put 操作,将使用上述的 $token 进行上传。
// 常用于自动触发持久化处理 https://github.com/qiniu/php-sdk/blob/master/examples/upload_and_pfop.php

$disk->getDriver()->downloadUrl('file.jpg'); //获取下载地址
$disk->getDriver()->downloadUrl('file.jpg')
$disk->getAdapter()->downloadUrl('file.jpg'); //获取下载地址
$disk->getAdapter()->downloadUrl('file.jpg')
->setDownload('foo.jpg'); //获取下载地址,文件名为 foo.jpg
$disk->getDriver()->downloadUrl('file.jpg', 'https'); //获取HTTPS下载地址
$disk->getDriver()->privateDownloadUrl('file.jpg'); //获取私有bucket下载地址
$disk->getDriver()->privateDownloadUrl('file.jpg?attname=foo.jpg');
$disk->getAdapter()->downloadUrl('file.jpg', 'https'); //获取HTTPS下载地址
$disk->getAdapter()->privateDownloadUrl('file.jpg'); //获取私有bucket下载地址
$disk->getAdapter()->privateDownloadUrl('file.jpg?attname=foo.jpg');
//获取私有bucket下载地址,文件名为 foo.jpg
$disk->getDriver()->privateDownloadUrl('file.jpg', 'https');//获取私有bucket的HTTPS下载地址
$disk->getDriver()->privateDownloadUrl('file.jpg',
$disk->getAdapter()->privateDownloadUrl('file.jpg', 'https');//获取私有bucket的HTTPS下载地址
$disk->getAdapter()->privateDownloadUrl('file.jpg',
[
'domain'=>'https',
'expires'=>3600
]); //获取私有bucket的HTTPS下载地址。超时 3600 秒。
$disk->getDriver()->avInfo('file.mp3'); //获取多媒体文件信息
$disk->getDriver()->imageInfo('file.jpg'); //获取图片信息
$disk->getDriver()->imageExif('file.jpg'); //获取图片EXIF信息
$disk->getDriver()->imagePreviewUrl('file.jpg','imageView2/0/w/100/h/200'); //获取图片预览URL
$disk->getDriver()->privateImagePreviewUrl('file.jpg','imageView2/0/w/100/h/200'); //获取私有bucket图片预览URL
$disk->getDriver()->verifyCallback('application/x-www-form-urlencoded', $request->header('Authorization'), 'callback url', $request->getContent());//验证回调内容是否合法
$disk->getDriver()->persistentFop('file.flv','avthumb/m3u8/segtime/40/vcodec/libx264/s/320x240'); //执行持久化数据处理
$disk->getDriver()->persistentFop('file.flv','fop','队列名'); //使用私有队列执行持久化数据处理
$disk->getDriver()->persistentStatus($persistent_fop_id); //查看持久化数据处理的状态。
$disk->getDriver()->fetch('http://abc.com/foo.jpg', 'bar.jpg'); //调用fetch将 foo.jpg 数据以 bar.jpg 的名字储存起来。
$disk->getDriver()->qetag(); //得到最后一次执行 put, copy, append 等写入操作后,得到的hash值。详见 https://github.com/qiniu/qetag
$disk->getDriver()->lastReturn(); //得到最后一次执行 put, copy, append 等写入操作后,得到的返回值。
$disk->getAdapter()->avInfo('file.mp3'); //获取多媒体文件信息
$disk->getAdapter()->imageInfo('file.jpg'); //获取图片信息
$disk->getAdapter()->imageExif('file.jpg'); //获取图片EXIF信息
$disk->getAdapter()->imagePreviewUrl('file.jpg','imageView2/0/w/100/h/200'); //获取图片预览URL
$disk->getAdapter()->privateImagePreviewUrl('file.jpg','imageView2/0/w/100/h/200'); //获取私有bucket图片预览URL
$disk->getAdapter()->verifyCallback('application/x-www-form-urlencoded', $request->header('Authorization'), 'callback url', $request->getContent());//验证回调内容是否合法
$disk->getAdapter()->persistentFop('file.flv','avthumb/m3u8/segtime/40/vcodec/libx264/s/320x240'); //执行持久化数据处理
$disk->getAdapter()->persistentFop('file.flv','fop','队列名'); //使用私有队列执行持久化数据处理
$disk->getAdapter()->persistentStatus($persistent_fop_id); //查看持久化数据处理的状态。
$disk->getAdapter()->fetch('http://abc.com/foo.jpg', 'bar.jpg'); //调用fetch将 foo.jpg 数据以 bar.jpg 的名字储存起来。
$disk->getAdapter()->qetag(); //得到最后一次执行 put, copy, append 等写入操作后,得到的hash值。详见 https://github.com/qiniu/qetag
$disk->getAdapter()->lastReturn(); //得到最后一次执行 put, copy, append 等写入操作后,得到的返回值。

```

第二种用法 (就是省略了一个getDriver
第二种用法 (就是省略了一个getAdapter

```php

Expand Down
15 changes: 0 additions & 15 deletions src/QiniuFilesystemServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,6 @@ function ($app, $config) {
isset($config['hotlink_prevention_key']) ? $config['hotlink_prevention_key'] : null
);
$file_system = new Filesystem($qiniu_adapter);
$file_system->addPlugin(new PrivateDownloadUrl());
$file_system->addPlugin(new DownloadUrl());
$file_system->addPlugin(new AvInfo());
$file_system->addPlugin(new ImageInfo());
$file_system->addPlugin(new ImageExif());
$file_system->addPlugin(new ImagePreviewUrl());
$file_system->addPlugin(new PersistentFop());
$file_system->addPlugin(new PersistentStatus());
$file_system->addPlugin(new UploadToken());
$file_system->addPlugin(new PrivateImagePreviewUrl());
$file_system->addPlugin(new VerifyCallback());
$file_system->addPlugin(new Fetch());
$file_system->addPlugin(new Qetag());
$file_system->addPlugin(new WithUploadToken());
$file_system->addPlugin(new LastReturn());

return new FilesystemAdapter($file_system, $qiniu_adapter, $config);
}
Expand Down
30 changes: 15 additions & 15 deletions src/QiniuStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function deleteDirectory($key)
*/
public function uploadToken($key = null, $expires = 3600, $policy = null, $strictPolicy = true)
{
return $this->storage->getDriver()->uploadToken($key, $expires, $policy, $strictPolicy);
return $this->storage->getAdapter()->uploadToken($key, $expires, $policy, $strictPolicy);
}

/**
Expand All @@ -170,7 +170,7 @@ public function uploadToken($key = null, $expires = 3600, $policy = null, $stric
*/
public function withUploadToken($token)
{
$this->storage->getDriver()->withUploadToken($token);
$this->storage->getAdapter()->withUploadToken($token);
}

/**
Expand All @@ -180,7 +180,7 @@ public function withUploadToken($token)
*/
public function downloadUrl($key, $domainType = 'default')
{
return $this->storage->getDriver()->downloadUrl($key, $domainType);
return $this->storage->getAdapter()->downloadUrl($key, $domainType);
}

/**
Expand All @@ -190,7 +190,7 @@ public function downloadUrl($key, $domainType = 'default')
*/
public function privateDownloadUrl($key, $domainType = 'default')
{
return $this->storage->getDriver()->privateDownloadUrl($key, $domainType);
return $this->storage->getAdapter()->privateDownloadUrl($key, $domainType);
}

/**
Expand All @@ -200,7 +200,7 @@ public function privateDownloadUrl($key, $domainType = 'default')
*/
public function avInfo($key)
{
return $this->storage->getDriver()->avInfo($key);
return $this->storage->getAdapter()->avInfo($key);
}

/**
Expand All @@ -210,7 +210,7 @@ public function avInfo($key)
*/
public function imageInfo($key)
{
return $this->storage->getDriver()->imageInfo($key);
return $this->storage->getAdapter()->imageInfo($key);
}

/**
Expand All @@ -220,7 +220,7 @@ public function imageInfo($key)
*/
public function imageExif($key)
{
return $this->storage->getDriver()->imageExif($key);
return $this->storage->getAdapter()->imageExif($key);
}

/**
Expand All @@ -231,7 +231,7 @@ public function imageExif($key)
*/
public function imagePreviewUrl($key, $opts)
{
return $this->storage->getDriver()->imagePreviewUrl($key, $opts);
return $this->storage->getAdapter()->imagePreviewUrl($key, $opts);
}

/**
Expand All @@ -242,7 +242,7 @@ public function imagePreviewUrl($key, $opts)
*/
public function privateImagePreviewUrl($key, $opts)
{
return $this->storage->getDriver()->privateImagePreviewUrl($key, $opts);
return $this->storage->getAdapter()->privateImagePreviewUrl($key, $opts);
}

/**
Expand All @@ -256,7 +256,7 @@ public function privateImagePreviewUrl($key, $opts)
*/
public function persistentFop($key, $opts, $pipline = null, $force = false, $notify_url = null)
{
return $this->storage->getDriver()->persistentFop($key, $opts, $pipline, $force, $notify_url);
return $this->storage->getAdapter()->persistentFop($key, $opts, $pipline, $force, $notify_url);
}

/**
Expand All @@ -266,7 +266,7 @@ public function persistentFop($key, $opts, $pipline = null, $force = false, $not
*/
public function persistentStatus($id)
{
return $this->storage->getDriver()->persistentStatus($id);
return $this->storage->getAdapter()->persistentStatus($id);
}

/**
Expand All @@ -276,7 +276,7 @@ public function persistentStatus($id)
*/
public function verifyCallback($contentType, $originAuthorization, $url, $body)
{
return $this->storage->getDriver()->verifyCallback($contentType, $originAuthorization, $url, $body);
return $this->storage->getAdapter()->verifyCallback($contentType, $originAuthorization, $url, $body);
}

/**
Expand All @@ -287,7 +287,7 @@ public function verifyCallback($contentType, $originAuthorization, $url, $body)
*/
public function fetch($url, $key)
{
return $this->storage->getDriver()->fetch($url, $key);
return $this->storage->getAdapter()->fetch($url, $key);
}

/**
Expand All @@ -296,7 +296,7 @@ public function fetch($url, $key)
*/
public function qetag()
{
return $this->storage->getDriver()->qetag();
return $this->storage->getAdapter()->qetag();
}

/**
Expand All @@ -305,6 +305,6 @@ public function qetag()
*/
public function lastReturn()
{
return $this->storage->getDriver()->getLastReturn();
return $this->storage->getAdapter()->getLastReturn();
}
}

0 comments on commit b4838a3

Please sign in to comment.