Skip to content

Commit

Permalink
Merge pull request zgldh#9 from branchzero/master
Browse files Browse the repository at this point in the history
Add VerifyCallback
  • Loading branch information
zgldh committed Jun 2, 2016
2 parents 5a5511d + 6ad9c95 commit c8d902e
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
$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); //查看持久化数据处理的状态。
Expand Down Expand Up @@ -112,6 +113,7 @@
$disk->imageExif('file.jpg'); //获取图片EXIF信息
$disk->imagePreviewUrl('file.jpg','imageView2/0/w/100/h/200'); //获取图片预览URL
$disk->privateImagePreviewUrl('file.jpg','imageView2/0/w/100/h/200'); //获取私有bucket图片预览URL
$disk->verifyCallback('application/x-www-form-urlencoded', $request->header('Authorization'), 'callback url', $request->getContent());//验证回调内容是否合法
$disk->persistentFop('file.flv','avthumb/m3u8/segtime/40/vcodec/libx264/s/320x240'); //执行持久化数据处理
$disk->persistentFop('file.flv','fop','队列名'); //使用私有队列执行持久化数据处理
$disk->persistentStatus($persistent_fop_id); //查看持久化数据处理的状态。
Expand All @@ -123,3 +125,5 @@

- https://github.com/qiniu/php-sdk
- http://developer.qiniu.com/docs/v6/sdk/php-sdk.html


37 changes: 37 additions & 0 deletions src/Plugins/verifyCallback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Created by PhpStorm.
* User: ZhangWB
* Date: 2015/4/21
* Time: 16:42
*/

namespace zgldh\QiniuStorage\Plugins;

use League\Flysystem\Plugin\AbstractPlugin;

/**
* Class verifyCallback
* 验证回调是否正确 <br>
* $disk = \Storage::disk('qiniu'); <br>
* $re = $disk->getDriver()->verifyCallback('application/x-www-form-urlencoded', $request->header('Authorization'), 'callback url', $request->getContent()); <br>
* @package zgldh\QiniuStorage\Plugins
*/
class VerifyCallback extends AbstractPlugin
{

/**
* Get the method name.
*
* @return string
*/
public function getMethod()
{
return 'verifyCallback';
}

public function handle($contentType = null, $originAuthorization = null, $url = null, $body = null)
{
return $this->filesystem->getAdapter()->verifyCallback($contentType, $originAuthorization, $url, $body);
}
}
9 changes: 8 additions & 1 deletion src/QiniuAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,11 @@ public function uploadToken(

return $token;
}
}

public function verifyCallback($contentType, $originAuthorization, $url, $body)
{
$auth = $this->getAuth();

return $auth->verifyCallback($contentType, $originAuthorization, $url, $body);
}
}
3 changes: 2 additions & 1 deletion src/QiniuFilesystemServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use zgldh\QiniuStorage\Plugins\PrivateDownloadUrl;
use zgldh\QiniuStorage\Plugins\UploadToken;
use zgldh\QiniuStorage\Plugins\PrivateImagePreviewUrl;
use zgldh\QiniuStorage\Plugins\VerifyCallback;

class QiniuFilesystemServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -45,8 +46,8 @@ function ($app, $config) {
$file_system->addPlugin(new PersistentFop());
$file_system->addPlugin(new PersistentStatus());
$file_system->addPlugin(new UploadToken());
$file_system->addPlugin(new UploadToken());
$file_system->addPlugin(new PrivateImagePreviewUrl());
$file_system->addPlugin(new VerifyCallback());

return $file_system;
}
Expand Down
12 changes: 11 additions & 1 deletion src/QiniuStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,14 @@ public function persistentStatus($id)
{
return $this->storage->getDriver()->persistentStatus($id);
}
}

/**
* 验证回调是否合法
* @param $id
* @return boolean
*/
public function verifyCallback($contentType, $originAuthorization, $url, $body)
{
return $this->storage->getDriver()->verifyCallback($contentType, $originAuthorization, $url, $body);
}
}

0 comments on commit c8d902e

Please sign in to comment.