Skip to content

Commit bdfe119

Browse files
committed
format php
1 parent ec68e37 commit bdfe119

File tree

9 files changed

+45
-52
lines changed

9 files changed

+45
-52
lines changed

demos/bucket_mgr.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
$auth = new Auth($accessKey, $secretKey);
1212

1313
//初始化BucketManager
14-
$bucketMgr = New BucketManager($auth);
14+
$bucketMgr = new BucketManager($auth);
1515

1616
//你要测试的空间, 并且这个key在你空间中存在
1717
$bucket = 'rwxf';
@@ -21,36 +21,36 @@
2121
list($ret, $err) = $bucketMgr->stat($bucket, $key);
2222
echo "\n====> $key stat : \n";
2323
if ($err !== null) {
24-
var_dump($err);
24+
var_dump($err);
2525
} else {
26-
var_dump($ret);
26+
var_dump($ret);
2727
}
2828

2929
//将文件从文件$key 复制到文件$key2。 可以在不同bucket复制
3030
$key2 = 'php-logo2.png';
3131
$err = $bucketMgr->copy($bucket, $key, $bucket, $key2);
3232
echo "\n====> copy $key to $key2 : \n";
3333
if ($err !== null) {
34-
var_dump($err);
34+
var_dump($err);
3535
} else {
36-
echo "Success!";
36+
echo "Success!";
3737
}
3838

3939
//将文件从文件$key2 移动到文件$key3。 可以在不同bucket移动
4040
$key3 = 'php-logo3.png';
4141
$err = $bucketMgr->move($bucket, $key2, $bucket, $key3);
4242
echo "\n====> move $key2 to $key3 : \n";
4343
if ($err !== null) {
44-
var_dump($err);
44+
var_dump($err);
4545
} else {
46-
echo "Success!";
46+
echo "Success!";
4747
}
4848

4949
//删除$bucket 中的文件 $key
5050
$err = $bucketMgr->delete($bucket, $key3);
5151
echo "\n====> delete $key3 : \n";
5252
if ($err !== null) {
53-
var_dump($err);
53+
var_dump($err);
5454
} else {
55-
echo "Success!";
55+
echo "Success!";
5656
}

demos/callback.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
use Qiniu\Auth;
55

6-
76
$accessKey = 'QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm';
87
$secretKey = 'Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz';
98
$auth = new Auth($accessKey, $secretKey);
@@ -23,9 +22,9 @@
2322
$isQiniuCallback = $auth->verifyCallback($contentType, $authorization, $url, $callbackBody);
2423

2524
if ($isQiniuCallback) {
26-
$resp = array('ret' => 'success');
25+
$resp = array('ret' => 'success');
2726
} else {
28-
$resp = array('ret' => 'failed');
27+
$resp = array('ret' => 'failed');
2928
}
3029

3130
echo json_encode($resp);

demos/download_token.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@
1515
$signedUrl = $auth->privateDownloadUrl($baseUrl);
1616

1717
echo $signedUrl;
18-

demos/fetch.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616

1717
list($ret, $err) = $bmgr->fetch($url, $bucket, $key);
1818
echo "=====> fetch $url to bucket: $bucket key: $key\n";
19-
if ($err !== null)
20-
{
21-
var_dump($err);
19+
if ($err !== null) {
20+
var_dump($err);
2221
} else {
23-
echo 'Success';
22+
echo 'Success';
2423
}
25-

demos/list_file.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$accessKey = 'XI0n2kV1LYwzcxqSZQxJ7bpycxDIAXFGJMWUt_zG';
88
$secretKey = '9WTmIAiwKQ2Nq6o93mfKd6VQqq56HjjLZonMWLJl';
99
$auth = new Auth($accessKey, $secretKey);
10-
$bucketMgr = New BucketManager($auth);
10+
$bucketMgr = new BucketManager($auth);
1111

1212
$bucket = 'rwxf';
1313
$prefix = '';
@@ -16,10 +16,10 @@
1616

1717
list($iterms, $marker, $err) = $bucketMgr->listFiles($bucket, $prefix, $marker, $limit);
1818
if ($err !== null) {
19-
echo "\n====> list file err: \n";
20-
var_dump($err);
19+
echo "\n====> list file err: \n";
20+
var_dump($err);
2121
} else {
22-
echo "Marker: $marker\n";
23-
echo "\nList Iterms====>\n";
24-
var_dump($iterms);
22+
echo "Marker: $marker\n";
23+
echo "\nList Iterms====>\n";
24+
var_dump($iterms);
2525
}

demos/mkzip.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Qiniu\Processing\PersistentFop;
66

77
// 去我们的portal 后台来获取AK, SK
8-
$accessKey = 'access key';
8+
$accessKey = 'access key';
99
$secretKey = 'secret key';
1010

1111
$accessKey = 'XI0n2kV1LYwzcxqSZQxJ7bpycxDIAXFGJMWUt_zG';
@@ -19,7 +19,7 @@
1919
// 异步任务的队列, 去后台新建: https://portal.qiniu.com/mps/pipeline
2020
$pipeline = 'abc';
2121

22-
$pfop = New PersistentFop($auth, $bucket, $pipeline);
22+
$pfop = new PersistentFop($auth, $bucket, $pipeline);
2323

2424
// 进行zip压缩的url
2525
$url1 = 'http://phpsdk.qiniudn.com/php-logo.png';
@@ -28,17 +28,17 @@
2828
//压缩后的key
2929
$zipKey = 'test.zip';
3030

31-
$fops = 'mkzip/2/url/' . \Qiniu\base64_urlSafeEncode($url1);
31+
$fops = 'mkzip/2/url/' . \Qiniu\base64_urlSafeEncode($url1);
3232
$fops .= '/url/' . \Qiniu\base64_urlSafeEncode($url2);
3333
$fops .= '|saveas/' . \Qiniu\base64_urlSafeEncode("$bucket:$zipKey");
3434

3535
list($id, $err) = $pfop->execute($key, $fops);
3636

3737
echo "\n====> pfop mkzip result: \n";
3838
if ($err != null) {
39-
var_dump($err);
39+
var_dump($err);
4040
} else {
41-
echo "PersistentFop Id: $id\n";
41+
echo "PersistentFop Id: $id\n";
4242

4343
$res = "http://api.qiniu.com/status/get/prefop?id=$id";
4444
echo "Processing result: $res";

demos/pfop.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,24 @@
1616

1717
//转码是使用的队列名称。 https://portal.qiniu.com/mps/pipeline
1818
$pipeline = 'abc';
19-
$pfop = New PersistentFop($auth, $bucket, $pipeline);
19+
$pfop = new PersistentFop($auth, $bucket, $pipeline);
2020

2121
//要进行转码的转码操作。 http://developer.qiniu.com/docs/v6/api/reference/fop/av/avthumb.html
2222
$fops = "avthumb/mp4/s/640x360/vb/1.25m";
2323

2424
list($id, $err) = $pfop->execute($key, $fops);
2525
echo "\n====> pfop avthumb result: \n";
2626
if ($err != null) {
27-
var_dump($err);
27+
var_dump($err);
2828
} else {
29-
echo "PersistentFop Id: $id\n";
29+
echo "PersistentFop Id: $id\n";
3030
}
3131

3232
//查询转码的进度和状态
33-
list($ret, $err) = $pfop->status($id);
33+
list($ret, $err) = $pfop->status($id);
3434
echo "\n====> pfop avthumb status: \n";
3535
if ($err != null) {
36-
var_dump($err);
36+
var_dump($err);
3737
} else {
38-
var_dump($ret);
38+
var_dump($ret);
3939
}
40-

demos/up.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
$bucket = 'phpsdk';
1212
$token = $auth->uploadToken($bucket);
13-
$uploadMgr = New UploadManager();
13+
$uploadMgr = new UploadManager();
1414

1515
//----------------------------------------upload demo1 ----------------------------------------
1616
// 上传字符串到七牛
1717
list($ret, $err) = $uploadMgr->put($token, null, 'content string');
1818
echo "\n====> put result: \n";
1919
if ($err !== null) {
20-
var_dump($err);
20+
var_dump($err);
2121
} else {
22-
var_dump($ret);
22+
var_dump($ret);
2323
}
2424

2525

@@ -30,30 +30,30 @@
3030
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
3131
echo "\n====> putFile result: \n";
3232
if ($err !== null) {
33-
var_dump($err);
33+
var_dump($err);
3434
} else {
35-
var_dump($ret);
35+
var_dump($ret);
3636
}
3737

3838

3939
//----------------------------------------upload demo3 ----------------------------------------
4040
// 上传文件到七牛后, 七牛将文件名和文件大小回调给业务服务器.
4141
// 可参考文档: http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html
4242
$policy = array(
43-
'callbackUrl' => 'http://172.30.251.210/callback.php',
44-
'callbackBody' => 'filename=$(fname)&filesize=$(fsize)'
45-
// 'callbackBodyType' => 'application/json',
46-
// 'callbackBody' => '{"filename":$(fname), "filesize": $(fsize)}' //设置application/json格式回调
43+
'callbackUrl' => 'http://172.30.251.210/callback.php',
44+
'callbackBody' => 'filename=$(fname)&filesize=$(fsize)'
45+
// 'callbackBodyType' => 'application/json',
46+
// 'callbackBody' => '{"filename":$(fname), "filesize": $(fsize)}' //设置application/json格式回调
4747
);
4848
$token = $auth->uploadToken($bucket, null, 3600, $policy);
4949

5050

5151
list($ret, $err) = $uploadMgr->putFile($token, null, $key);
5252
echo "\n====> putFile result: \n";
5353
if ($err !== null) {
54-
var_dump($err);
54+
var_dump($err);
5555
} else {
56-
var_dump($ret);
56+
var_dump($ret);
5757
}
5858

5959

@@ -69,7 +69,7 @@
6969
$pipeline = 'abc';
7070

7171
$policy = array(
72-
'persistentOps' => $pfop,
72+
'persistentOps' => $pfop,
7373
'persistentNotifyUrl' => $notifyUrl,
7474
'persistentPipeline' => $pipeline
7575
);
@@ -78,8 +78,7 @@
7878
list($ret, $err) = $uploadMgr->putFile($token, null, $key);
7979
echo "\n====> putFile result: \n";
8080
if ($err !== null) {
81-
var_dump($err);
81+
var_dump($err);
8282
} else {
83-
var_dump($ret);
83+
var_dump($ret);
8484
}
85-

demos/upload_token.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
$upToken = $auth->uploadToken($bucket);
1212

1313
echo $upToken;
14-

0 commit comments

Comments
 (0)