|
10 | 10 |
|
11 | 11 | $bucket = 'phpsdk'; |
12 | 12 | $token = $auth->uploadToken($bucket); |
13 | | -$uploadMgr = New UploadManager(); |
| 13 | +$uploadMgr = new UploadManager(); |
14 | 14 |
|
15 | 15 | //----------------------------------------upload demo1 ---------------------------------------- |
16 | 16 | // 上传字符串到七牛 |
17 | 17 | list($ret, $err) = $uploadMgr->put($token, null, 'content string'); |
18 | 18 | echo "\n====> put result: \n"; |
19 | 19 | if ($err !== null) { |
20 | | - var_dump($err); |
| 20 | + var_dump($err); |
21 | 21 | } else { |
22 | | - var_dump($ret); |
| 22 | + var_dump($ret); |
23 | 23 | } |
24 | 24 |
|
25 | 25 |
|
|
30 | 30 | list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath); |
31 | 31 | echo "\n====> putFile result: \n"; |
32 | 32 | if ($err !== null) { |
33 | | - var_dump($err); |
| 33 | + var_dump($err); |
34 | 34 | } else { |
35 | | - var_dump($ret); |
| 35 | + var_dump($ret); |
36 | 36 | } |
37 | 37 |
|
38 | 38 |
|
39 | 39 | //----------------------------------------upload demo3 ---------------------------------------- |
40 | 40 | // 上传文件到七牛后, 七牛将文件名和文件大小回调给业务服务器. |
41 | 41 | // 可参考文档: http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html |
42 | 42 | $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格式回调 |
47 | 47 | ); |
48 | 48 | $token = $auth->uploadToken($bucket, null, 3600, $policy); |
49 | 49 |
|
50 | 50 |
|
51 | 51 | list($ret, $err) = $uploadMgr->putFile($token, null, $key); |
52 | 52 | echo "\n====> putFile result: \n"; |
53 | 53 | if ($err !== null) { |
54 | | - var_dump($err); |
| 54 | + var_dump($err); |
55 | 55 | } else { |
56 | | - var_dump($ret); |
| 56 | + var_dump($ret); |
57 | 57 | } |
58 | 58 |
|
59 | 59 |
|
|
69 | 69 | $pipeline = 'abc'; |
70 | 70 |
|
71 | 71 | $policy = array( |
72 | | - 'persistentOps' => $pfop, |
| 72 | + 'persistentOps' => $pfop, |
73 | 73 | 'persistentNotifyUrl' => $notifyUrl, |
74 | 74 | 'persistentPipeline' => $pipeline |
75 | 75 | ); |
|
78 | 78 | list($ret, $err) = $uploadMgr->putFile($token, null, $key); |
79 | 79 | echo "\n====> putFile result: \n"; |
80 | 80 | if ($err !== null) { |
81 | | - var_dump($err); |
| 81 | + var_dump($err); |
82 | 82 | } else { |
83 | | - var_dump($ret); |
| 83 | + var_dump($ret); |
84 | 84 | } |
85 | | - |
0 commit comments