diff --git a/examples/auth.php b/examples/auth.php new file mode 100644 index 00000000..1ddbec02 --- /dev/null +++ b/examples/auth.php @@ -0,0 +1,11 @@ +copy($bucket, $key, $bucket, $key2); +echo "\n====> copy $key to $key2 : \n"; +if ($err !== null) { + var_dump($err); +} else { + echo "Success!"; +} diff --git a/examples/file_delete.php b/examples/file_delete.php new file mode 100644 index 00000000..a24589d7 --- /dev/null +++ b/examples/file_delete.php @@ -0,0 +1,27 @@ +delete($bucket, $key); +echo "\n====> delete $key : \n"; +if ($err !== null) { + var_dump($err); +} else { + echo "Success!"; +} diff --git a/examples/file_move.php b/examples/file_move.php new file mode 100644 index 00000000..a8ff1d45 --- /dev/null +++ b/examples/file_move.php @@ -0,0 +1,28 @@ +move($bucket, $key2, $bucket, $key3); +echo "\n====> move $key to $key2 : \n"; +if ($err !== null) { + var_dump($err); +} else { + echo "Success!"; +} diff --git a/examples/file_stat.php b/examples/file_stat.php new file mode 100644 index 00000000..1c884990 --- /dev/null +++ b/examples/file_stat.php @@ -0,0 +1,27 @@ +stat($bucket, $key); +echo "\n====> $key stat : \n"; +if ($err !== null) { + var_dump($err); +} else { + var_dump($ret); +} diff --git a/examples/list_file.php b/examples/list_file.php index 5bfdb4d0..efe5a523 100644 --- a/examples/list_file.php +++ b/examples/list_file.php @@ -9,11 +9,20 @@ $auth = new Auth($accessKey, $secretKey); $bucketMgr = new BucketManager($auth); +// http://developer.qiniu.com/docs/v6/api/reference/rs/list.html#list-description +// 要列取的空间名称 $bucket = 'Bucket_Name'; + +// 要列取文件的公共前缀 $prefix = ''; + +// 上次列举返回的位置标记,作为本次列举的起点信息。 $marker = ''; + +// 本次列举的条目数 $limit = 3; +// 列举文件 list($iterms, $marker, $err) = $bucketMgr->listFiles($bucket, $prefix, $marker, $limit); if ($err !== null) { echo "\n====> list file err: \n"; diff --git a/examples/mkzip.php b/examples/mkzip.php index 47594144..6c8ac59d 100644 --- a/examples/mkzip.php +++ b/examples/mkzip.php @@ -4,6 +4,7 @@ use Qiniu\Auth; use Qiniu\Processing\PersistentFop; +// 去我们的portal 后台来获取AK, SK $accessKey = 'Access_Key'; $secretKey = 'Secret_Key'; $auth = new Auth($accessKey, $secretKey); @@ -13,13 +14,13 @@ $key = '1.png'; // 异步任务的队列, 去后台新建: https://portal.qiniu.com/mps/pipeline -$pipeline = 'abc'; +$pipeline = 'pipeline_name'; $pfop = new PersistentFop($auth, $bucket, $pipeline); // 进行zip压缩的url -$url1 = 'http://Bucket_Name.qiniudn.com/php-logo.png'; -$url2 = 'http://Bucket_Name.qiniudn.com/php-sdk.html'; +$url1 = 'http://rwxf.qiniudn.com/php-logo.png'; +$url2 = 'http://rwxf.qiniudn.com/1.png'; //压缩后的key $zipKey = 'test.zip'; diff --git a/examples/notify.php b/examples/notify.php new file mode 100644 index 00000000..0cb8d9e6 --- /dev/null +++ b/examples/notify.php @@ -0,0 +1,7 @@ +execute($key, $fops); echo "\n====> pfop avthumb result: \n"; diff --git a/examples/persistent_fop_init.php b/examples/persistent_fop_init.php new file mode 100644 index 00000000..2df01e9f --- /dev/null +++ b/examples/persistent_fop_init.php @@ -0,0 +1,19 @@ +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); +} diff --git a/examples/upload_and_callback.php b/examples/upload_and_callback.php new file mode 100644 index 00000000..4b6cbf6c --- /dev/null +++ b/examples/upload_and_callback.php @@ -0,0 +1,31 @@ + '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); +} diff --git a/examples/upload_and_pfop.php b/examples/upload_and_pfop.php new file mode 100644 index 00000000..d123b8bb --- /dev/null +++ b/examples/upload_and_pfop.php @@ -0,0 +1,40 @@ +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); +} diff --git a/examples/upload_mgr_init.php b/examples/upload_mgr_init.php new file mode 100644 index 00000000..3459ef1d --- /dev/null +++ b/examples/upload_mgr_init.php @@ -0,0 +1,18 @@ +uploadToken($bucket); + +// 构建 UploadManager 对象 +$uploadMgr = new UploadManager();