-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
324 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Auth; | ||
|
||
// 用于签名的公钥和私钥. http://developer.qiniu.com/docs/v6/api/overview/security.html#aksk | ||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
|
||
// 初始化签权对象。 | ||
$auth = new Auth($accessKey, $secretKey); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Auth; | ||
use Qiniu\Storage\BucketManager; | ||
|
||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
|
||
//初始化Auth状态: | ||
$auth = new Auth($accessKey, $secretKey); | ||
|
||
//初始化BucketManager | ||
$bucketMgr = new BucketManager($auth); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Auth; | ||
use Qiniu\Storage\BucketManager; | ||
|
||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
|
||
//初始化Auth状态: | ||
$auth = new Auth($accessKey, $secretKey); | ||
|
||
//初始化BucketManager | ||
$bucketMgr = new BucketManager($auth); | ||
|
||
//你要测试的空间, 并且这个key在你空间中存在 | ||
$bucket = 'Bucket_Name'; | ||
$key = 'php-logo.png'; | ||
|
||
//将文件从文件$key 复制到文件$key2。 可以在不同bucket复制 | ||
$key2 = 'php-logo2.png'; | ||
$err = $bucketMgr->copy($bucket, $key, $bucket, $key2); | ||
echo "\n====> copy $key to $key2 : \n"; | ||
if ($err !== null) { | ||
var_dump($err); | ||
} else { | ||
echo "Success!"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Auth; | ||
use Qiniu\Storage\BucketManager; | ||
|
||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
|
||
//初始化Auth状态: | ||
$auth = new Auth($accessKey, $secretKey); | ||
|
||
//初始化BucketManager | ||
$bucketMgr = new BucketManager($auth); | ||
|
||
//你要测试的空间, 并且这个key在你空间中存在 | ||
$bucket = 'Bucket_Name'; | ||
$key = 'php-logo.png'; | ||
|
||
//删除$bucket 中的文件 $key | ||
$err = $bucketMgr->delete($bucket, $key); | ||
echo "\n====> delete $key : \n"; | ||
if ($err !== null) { | ||
var_dump($err); | ||
} else { | ||
echo "Success!"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Auth; | ||
use Qiniu\Storage\BucketManager; | ||
|
||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
|
||
//初始化Auth状态: | ||
$auth = new Auth($accessKey, $secretKey); | ||
|
||
//初始化BucketManager | ||
$bucketMgr = new BucketManager($auth); | ||
|
||
//你要测试的空间, 并且这个key在你空间中存在 | ||
$bucket = 'Bucket_Name'; | ||
$key = 'php-logo.png'; | ||
|
||
//将文件从文件$key 改成文件名$key2。 可以在不同bucket移动 | ||
$key3 = 'php-logo3.png'; | ||
$err = $bucketMgr->move($bucket, $key2, $bucket, $key3); | ||
echo "\n====> move $key to $key2 : \n"; | ||
if ($err !== null) { | ||
var_dump($err); | ||
} else { | ||
echo "Success!"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Auth; | ||
use Qiniu\Storage\BucketManager; | ||
|
||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
|
||
//初始化Auth状态: | ||
$auth = new Auth($accessKey, $secretKey); | ||
|
||
//初始化BucketManager | ||
$bucketMgr = new BucketManager($auth); | ||
|
||
//你要测试的空间, 并且这个key在你空间中存在 | ||
$bucket = 'Bucket_Name'; | ||
$key = 'php-logo.png'; | ||
|
||
//获取文件的状态信息 | ||
list($ret, $err) = $bucketMgr->stat($bucket, $key); | ||
echo "\n====> $key stat : \n"; | ||
if ($err !== null) { | ||
var_dump($err); | ||
} else { | ||
var_dump($ret); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
// 获取notify通知的body信息 | ||
$notifyBody = file_get_contents('php://input'); | ||
|
||
// 业务服务器处理通知信息, 这里直接打印在log中 | ||
error_log($notifyBody); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Auth; | ||
use Qiniu\Processing\PersistentFop; | ||
|
||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
$auth = new Auth($accessKey, $secretKey); | ||
|
||
// 要转码的文件所在的空间。 | ||
$bucket = 'Bucket_Name'; | ||
|
||
// 转码是使用的队列名称。 https://portal.qiniu.com/mps/pipeline | ||
$pipeline = 'pipeline_name'; | ||
|
||
// 初始化 | ||
$pfop = new PersistentFop($auth, $bucket, $pipeline); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Processing\PersistentFop; | ||
|
||
// 触发持久化处理后返回的 Id | ||
$persistentId = 'z0.564d5f977823de48a85ece59'; | ||
|
||
// 通过persistentId查询该 触发持久化处理的状态 | ||
$status = PersistentFop::status($persistentId); | ||
|
||
var_dump($status); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
// 引入鉴权类 | ||
use Qiniu\Auth; | ||
|
||
// 引入上传类 | ||
use Qiniu\Storage\UploadManager; | ||
|
||
// 需要填写你的 Access Key 和 Secret Key | ||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
|
||
// 构建鉴权对象 | ||
$auth = new Auth($accessKey, $secretKey); | ||
|
||
// 要上传的空间 | ||
$bucket = 'Bucket_Name'; | ||
|
||
// 生成上传 Token | ||
$token = $auth->uploadToken($bucket); | ||
|
||
// 要上传文件的本地路径 | ||
$filePath = './php-logo.png'; | ||
|
||
// 上传到七牛后保存的文件名 | ||
$key = 'my-php-logo.png'; | ||
|
||
// 初始化 UploadManager 对象并进行文件的上传。 | ||
$uploadMgr = new UploadManager(); | ||
|
||
// 调用 UploadManager 的 putFile 方法进行文件的上传。 | ||
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath); | ||
echo "\n====> putFile result: \n"; | ||
if ($err !== null) { | ||
var_dump($err); | ||
} else { | ||
var_dump($ret); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Auth; | ||
use Qiniu\Storage\UploadManager; | ||
|
||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
$auth = new Auth($accessKey, $secretKey); | ||
|
||
$bucket = 'Bucket_Name'; | ||
// 上传文件到七牛后, 七牛将文件名和文件大小回调给业务服务器. | ||
// 可参考文档: http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html | ||
$policy = array( | ||
'callbackUrl' => 'http://your.domain.com/callback.php', | ||
'callbackBody' => 'filename=$(fname)&filesize=$(fsize)' | ||
); | ||
$uptoken = $auth->uploadToken($bucket, null, 3600, $policy); | ||
|
||
//上传文件的本地路径 | ||
$filePath = './php-logo.png'; | ||
|
||
$uploadMgr = new UploadManager(); | ||
|
||
list($ret, $err) = $uploadMgr->putFile($uptoken, null, $filePath); | ||
echo "\n====> putFile result: \n"; | ||
if ($err !== null) { | ||
var_dump($err); | ||
} else { | ||
var_dump($ret); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Auth; | ||
use Qiniu\Storage\UploadManager; | ||
|
||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
$auth = new Auth($accessKey, $secretKey); | ||
|
||
$bucket = 'Bucket_Name'; | ||
// 在七牛保存的文件名 | ||
$key = 'php-logo.png'; | ||
$token = $auth->uploadToken($bucket); | ||
$uploadMgr = new UploadManager(); | ||
|
||
//上传视频,上传完成后进行m3u8的转码, 并给视频打水印 | ||
$wmImg = Qiniu\base64_urlSafeEncode('http://Bucket_Name.qiniudn.com/logo-s.png'); | ||
$pfop = "avthumb/m3u8/wmImage/$wmImg"; | ||
|
||
//转码完成后通知到你的业务服务器。(公网可以访问,并相应200 OK) | ||
$notifyUrl = 'http://notify.fake.com'; | ||
|
||
//独立的转码队列:https://portal.qiniu.com/mps/pipeline | ||
$pipeline = 'pipeline_name'; | ||
|
||
$policy = array( | ||
'persistentOps' => $pfop, | ||
'persistentNotifyUrl' => $notifyUrl, | ||
'persistentPipeline' => $pipeline | ||
); | ||
$token = $auth->uploadToken($bucket, null, 3600, $policy); | ||
|
||
list($ret, $err) = $uploadMgr->putFile($token, null, $key); | ||
echo "\n====> putFile result: \n"; | ||
if ($err !== null) { | ||
var_dump($err); | ||
} else { | ||
var_dump($ret); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
require_once __DIR__ . '/../autoload.php'; | ||
|
||
use Qiniu\Auth; | ||
use Qiniu\Storage\UploadManager; | ||
|
||
$accessKey = 'Access_Key'; | ||
$secretKey = 'Secret_Key'; | ||
$auth = new Auth($accessKey, $secretKey); | ||
|
||
// 空间名 http://developer.qiniu.com/docs/v6/api/overview/concepts.html#bucket | ||
$bucket = 'Bucket_Name'; | ||
|
||
// 生成上传Token | ||
$token = $auth->uploadToken($bucket); | ||
|
||
// 构建 UploadManager 对象 | ||
$uploadMgr = new UploadManager(); |