@@ -10,22 +10,22 @@ |
||
10 | 10 | |
11 | 11 | class WantuFileServiceProvider extends ServiceProvider |
12 | 12 | { |
13 | - public function boot() |
|
14 | - { |
|
15 | - app('filesystem')->extend('wantu', function ($app, $config) { |
|
16 | - $adapter = new WantuFileAdapter( |
|
17 | - $config['access_key'], |
|
18 | - $config['secret_key'], |
|
19 | - $config['namespace'], |
|
20 | - $config['domain'] |
|
21 | - ); |
|
22 | - $flysystem = new Filesystem($adapter, new Config(['disable_asserts' => true])); |
|
23 | - // $flysystem->addPlugin(new FetchFile()); |
|
24 | - $flysystem->addPlugin(new UploadToken()); |
|
25 | - $flysystem->addPlugin(new GetUrl()); |
|
26 | - // $flysystem->addPlugin(new PrivateDownloadUrl()); |
|
27 | - // $flysystem->addPlugin(new RefreshFile()); |
|
28 | - return $flysystem; |
|
29 | - }); |
|
30 | - } |
|
13 | + public function boot() |
|
14 | + { |
|
15 | + app('filesystem')->extend('wantu', function ($app, $config) { |
|
16 | + $adapter = new WantuFileAdapter( |
|
17 | + $config['access_key'], |
|
18 | + $config['secret_key'], |
|
19 | + $config['namespace'], |
|
20 | + $config['domain'] |
|
21 | + ); |
|
22 | + $flysystem = new Filesystem($adapter, new Config(['disable_asserts' => true])); |
|
23 | + // $flysystem->addPlugin(new FetchFile()); |
|
24 | + $flysystem->addPlugin(new UploadToken()); |
|
25 | + $flysystem->addPlugin(new GetUrl()); |
|
26 | + // $flysystem->addPlugin(new PrivateDownloadUrl()); |
|
27 | + // $flysystem->addPlugin(new RefreshFile()); |
|
28 | + return $flysystem; |
|
29 | + }); |
|
30 | + } |
|
31 | 31 | } |
@@ -5,13 +5,13 @@ |
||
5 | 5 | |
6 | 6 | class UploadToken extends AbstractPlugin |
7 | 7 | { |
8 | - public function getMethod() |
|
9 | - { |
|
10 | - return 'getUploadToken'; |
|
11 | - } |
|
8 | + public function getMethod() |
|
9 | + { |
|
10 | + return 'getUploadToken'; |
|
11 | + } |
|
12 | 12 | |
13 | - public function handle($option = null) |
|
14 | - { |
|
15 | - return $this->filesystem->getAdapter()->getUploadToken($option); |
|
16 | - } |
|
13 | + public function handle($option = null) |
|
14 | + { |
|
15 | + return $this->filesystem->getAdapter()->getUploadToken($option); |
|
16 | + } |
|
17 | 17 | } |
@@ -5,12 +5,12 @@ |
||
5 | 5 | |
6 | 6 | class GetUrl extends AbstractPlugin |
7 | 7 | { |
8 | - public function getMethod() |
|
9 | - { |
|
10 | - return 'getUrl'; |
|
11 | - } |
|
12 | - public function handle($path) |
|
13 | - { |
|
14 | - return $this->filesystem->getAdapter()->getUrl($path); |
|
15 | - } |
|
8 | + public function getMethod() |
|
9 | + { |
|
10 | + return 'getUrl'; |
|
11 | + } |
|
12 | + public function handle($path) |
|
13 | + { |
|
14 | + return $this->filesystem->getAdapter()->getUrl($path); |
|
15 | + } |
|
16 | 16 | } |
@@ -12,389 +12,389 @@ |
||
12 | 12 | |
13 | 13 | class WantuFileAdapter extends AbstractAdapter |
14 | 14 | { |
15 | - use NotSupportingVisibilityTrait; |
|
16 | - |
|
17 | - /** |
|
18 | - * @var Client|null |
|
19 | - */ |
|
20 | - private $client = null; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - private $namespace = null; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - private $domain = null; |
|
31 | - |
|
32 | - /** |
|
33 | - * @param string $accessKey |
|
34 | - * @param string $secretKey |
|
35 | - * @param string $namespace |
|
36 | - */ |
|
37 | - public function __construct($accessKey, $secretKey, $namespace, $origin) |
|
38 | - { |
|
39 | - $client = new Client($accessKey, $secretKey, $namespace); |
|
40 | - $this->setClient($client, $namespace, $origin); |
|
41 | - } |
|
42 | - |
|
43 | - public function setClient(Client $client, $namespace, $origin) |
|
44 | - { |
|
45 | - $this->client = $client; |
|
46 | - $this->namespace = $namespace; |
|
47 | - $this->domain = $origin; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Write a new file. |
|
52 | - * |
|
53 | - * @param string $path |
|
54 | - * @param string $contents |
|
55 | - * @param Config $config Config object |
|
56 | - * |
|
57 | - * @return array|false false on failure file meta data on success |
|
58 | - */ |
|
59 | - public function write($path, $contents, Config $config) |
|
60 | - { |
|
61 | - $uploadPolicy = new UploadPolicy([ |
|
62 | - 'namespace' => $this->namespace, |
|
63 | - 'dir' => preg_replace('/^\./', '', dirname($path)), |
|
64 | - 'name' => last(explode("/", $path)), |
|
65 | - ]); |
|
66 | - |
|
67 | - return $this->client->uploadData($contents, $uploadPolicy); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Write a new file using a stream. |
|
72 | - * |
|
73 | - * @param string $path |
|
74 | - * @param resource $resource |
|
75 | - * @param Config $config Config object |
|
76 | - * |
|
77 | - * @return array|false false on failure file meta data on success |
|
78 | - */ |
|
79 | - public function writeStream($path, $resource, Config $config) |
|
80 | - { |
|
81 | - $contents = ''; |
|
82 | - |
|
83 | - while (!feof($resource)) { |
|
84 | - $contents .= fread($resource, 1024); |
|
85 | - } |
|
86 | - |
|
87 | - $response = $this->write($path, $contents, $config); |
|
88 | - |
|
89 | - if (false === $response) { |
|
90 | - return $response; |
|
91 | - } |
|
92 | - |
|
93 | - return compact('path'); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Update a file. |
|
98 | - * |
|
99 | - * @param string $path |
|
100 | - * @param string $contents |
|
101 | - * @param Config $config Config object |
|
102 | - * |
|
103 | - * @return array|false false on failure file meta data on success |
|
104 | - */ |
|
105 | - public function update($path, $contents, Config $config) |
|
106 | - { |
|
107 | - $this->delete($path); |
|
108 | - |
|
109 | - return $this->write($path, $contents, $config); |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Update a file using a stream. |
|
114 | - * |
|
115 | - * @param string $path |
|
116 | - * @param resource $resource |
|
117 | - * @param Config $config Config object |
|
118 | - * |
|
119 | - * @return array|false false on failure file meta data on success |
|
120 | - */ |
|
121 | - public function updateStream($path, $resource, Config $config) |
|
122 | - { |
|
123 | - $this->delete($path); |
|
124 | - |
|
125 | - return $this->writeStream($path, $resource, $config); |
|
126 | - } |
|
127 | - |
|
128 | - public function put($path, $contents, Config $config) |
|
129 | - { |
|
130 | - return $this->write($path, $contents, $config); |
|
131 | - } |
|
132 | - |
|
133 | - public function putStream($path, $resource, Config $config) |
|
134 | - { |
|
135 | - return $this->write($path, $resource, $config); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Rename a file. |
|
140 | - * |
|
141 | - * @param string $path |
|
142 | - * @param string $newpath |
|
143 | - * |
|
144 | - * @return bool |
|
145 | - */ |
|
146 | - public function rename($path, $newpath) |
|
147 | - { |
|
148 | - return $this->client->renameFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)), preg_replace('/^\./', '', dirname($newpath)), last(explode("/", $newpath))); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * Copy a file. |
|
153 | - * |
|
154 | - * @param string $path |
|
155 | - * @param string $newpath |
|
156 | - * |
|
157 | - * @return bool |
|
158 | - */ |
|
159 | - public function copy($path, $newpath) |
|
160 | - { |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Delete a file. |
|
165 | - * |
|
166 | - * @param string $path |
|
167 | - * |
|
168 | - * @return bool |
|
169 | - */ |
|
170 | - public function delete($path) |
|
171 | - { |
|
172 | - return $this->client->deleteFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path))); |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Delete a directory. |
|
177 | - * |
|
178 | - * @param string $dirname |
|
179 | - * |
|
180 | - * @return bool |
|
181 | - */ |
|
182 | - public function deleteDir($dirname) |
|
183 | - { |
|
184 | - return $this->client->deleteDir($this->namespace, $dirname); |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * Create a directory. |
|
189 | - * |
|
190 | - * @param string $dirname directory name |
|
191 | - * @param Config $config |
|
192 | - * |
|
193 | - * @return array|false |
|
194 | - */ |
|
195 | - public function createDir($dirname, Config $config) |
|
196 | - { |
|
197 | - return $this->client->createDir($this->namespace, $dirname); |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Check whether a file exists. |
|
202 | - * |
|
203 | - * @param string $path |
|
204 | - * |
|
205 | - * @return array|bool|null |
|
206 | - */ |
|
207 | - public function has($path) |
|
208 | - { |
|
209 | - if (Str::endsWith($path, "/")) { |
|
210 | - return $this->client->existsFolder($this->namespace, preg_replace('/^\./', '', dirname($path))); |
|
211 | - } else { |
|
212 | - return $this->client->existsFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path))); |
|
213 | - } |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * Read a file. |
|
219 | - * |
|
220 | - * @param string $path |
|
221 | - * |
|
222 | - * @return array|false |
|
223 | - */ |
|
224 | - public function read($path) |
|
225 | - { |
|
226 | - $contents = file_get_contents($this->getUrl($path)); |
|
227 | - return compact('contents', 'path'); |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Read a file as a stream. |
|
232 | - * |
|
233 | - * @param string $path |
|
234 | - * |
|
235 | - * @return array|false |
|
236 | - */ |
|
237 | - public function readStream($path) |
|
238 | - { |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * List contents of a directory. |
|
243 | - * |
|
244 | - * @param string $directory |
|
245 | - * @param bool $recursive |
|
246 | - * |
|
247 | - * @return array |
|
248 | - */ |
|
249 | - public function listContents($directory = '', $recursive = false) |
|
250 | - { |
|
251 | - return $this->client->listFiles($this->namespace, $directory, 1, 1000); |
|
252 | - } |
|
253 | - |
|
254 | - /** |
|
255 | - * Get all the meta data of a file or directory. |
|
256 | - * |
|
257 | - * @param string $path |
|
258 | - * |
|
259 | - * @return array|false |
|
260 | - */ |
|
261 | - public function getMetadata($path) |
|
262 | - { |
|
263 | - return $this->client->getFileInfo($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path))); |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * Get the size of a file. |
|
268 | - * |
|
269 | - * @param string $path |
|
270 | - * |
|
271 | - * @return array|false |
|
272 | - */ |
|
273 | - public function getSize($path) |
|
274 | - { |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * Fetch url to bucket. |
|
280 | - * |
|
281 | - * @param string $path |
|
282 | - * @param string $url |
|
283 | - * |
|
284 | - * @return array|false |
|
285 | - */ |
|
286 | - public function fetch($path, $url) |
|
287 | - { |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * Get private file download url. |
|
292 | - * |
|
293 | - * @param string $path |
|
294 | - * @param int $expires |
|
295 | - * |
|
296 | - * @return string |
|
297 | - */ |
|
298 | - public function privateDownloadUrl($path, $expires = 3600) |
|
299 | - { |
|
300 | - } |
|
301 | - |
|
302 | - /** |
|
303 | - * Refresh file cache. |
|
304 | - * |
|
305 | - * @param string|array $path |
|
306 | - * |
|
307 | - * @return array |
|
308 | - */ |
|
309 | - public function refresh($path) |
|
310 | - { |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - /** |
|
315 | - * Get the mime-type of a file. |
|
316 | - * |
|
317 | - * @param string $path |
|
318 | - * |
|
319 | - * @return array|false |
|
320 | - */ |
|
321 | - public function getMimeType($path) |
|
322 | - { |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * Get the timestamp of a file. |
|
328 | - * |
|
329 | - * @param string $path |
|
330 | - * |
|
331 | - * @return array|false |
|
332 | - */ |
|
333 | - public function getTimestamp($path) |
|
334 | - { |
|
335 | - } |
|
336 | - |
|
337 | - /** |
|
338 | - * Get the upload token. |
|
339 | - * |
|
340 | - * @param string|null $key |
|
341 | - * @param int $ttl |
|
342 | - * @param string|null $policy |
|
343 | - * @param string|null $strictPolice |
|
344 | - * |
|
345 | - * @return string |
|
346 | - */ |
|
347 | - public function getUploadToken($option = null) |
|
348 | - { |
|
349 | - if ($option === null) { |
|
350 | - $option = ['name' => null, 'ttl' => 3600, ]; |
|
351 | - } elseif (!isset($option['ttl']) || !$option['ttl']) { |
|
352 | - $option['ttl'] = 3600; |
|
353 | - } |
|
354 | - |
|
355 | - return $this->client->getUploadToken(collect([ |
|
356 | - 'expiration' => Carbon::now()->addSeconds($option['ttl'])->timestamp * 1000, |
|
357 | - 'insertOnly' => Conf::INSERT_ONLY_TRUE |
|
358 | - ])->merge(collect($option)->except(['ttl',]))); |
|
359 | - } |
|
360 | - |
|
361 | - /** |
|
362 | - * @param array $stats |
|
363 | - * |
|
364 | - * @return array |
|
365 | - */ |
|
366 | - protected function normalizeFileInfo(array $stats) |
|
367 | - { |
|
368 | - return [ |
|
369 | - 'type' => 'file', |
|
370 | - 'path' => $stats['key'], |
|
371 | - 'timestamp' => floor($stats['putTime'] / 10000000), |
|
372 | - 'size' => $stats['fsize'], |
|
373 | - ]; |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * Get resource url. |
|
378 | - * |
|
379 | - * @param string $path |
|
380 | - * |
|
381 | - * @return string |
|
382 | - */ |
|
383 | - public function getUrl($path) |
|
384 | - { |
|
385 | - return $this->normalizeHost($this->domain) . ltrim($path, '/'); |
|
386 | - } |
|
387 | - |
|
388 | - /** |
|
389 | - * @param string $domain |
|
390 | - * |
|
391 | - * @return string |
|
392 | - */ |
|
393 | - protected function normalizeHost($domain) |
|
394 | - { |
|
395 | - if (0 !== stripos($domain, 'https://') && 0 !== stripos($domain, 'http://')) { |
|
396 | - $domain = "http://{$domain}"; |
|
397 | - } |
|
398 | - return rtrim($domain, '/') . '/'; |
|
399 | - } |
|
15 | + use NotSupportingVisibilityTrait; |
|
16 | + |
|
17 | + /** |
|
18 | + * @var Client|null |
|
19 | + */ |
|
20 | + private $client = null; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + private $namespace = null; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + private $domain = null; |
|
31 | + |
|
32 | + /** |
|
33 | + * @param string $accessKey |
|
34 | + * @param string $secretKey |
|
35 | + * @param string $namespace |
|
36 | + */ |
|
37 | + public function __construct($accessKey, $secretKey, $namespace, $origin) |
|
38 | + { |
|
39 | + $client = new Client($accessKey, $secretKey, $namespace); |
|
40 | + $this->setClient($client, $namespace, $origin); |
|
41 | + } |
|
42 | + |
|
43 | + public function setClient(Client $client, $namespace, $origin) |
|
44 | + { |
|
45 | + $this->client = $client; |
|
46 | + $this->namespace = $namespace; |
|
47 | + $this->domain = $origin; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Write a new file. |
|
52 | + * |
|
53 | + * @param string $path |
|
54 | + * @param string $contents |
|
55 | + * @param Config $config Config object |
|
56 | + * |
|
57 | + * @return array|false false on failure file meta data on success |
|
58 | + */ |
|
59 | + public function write($path, $contents, Config $config) |
|
60 | + { |
|
61 | + $uploadPolicy = new UploadPolicy([ |
|
62 | + 'namespace' => $this->namespace, |
|
63 | + 'dir' => preg_replace('/^\./', '', dirname($path)), |
|
64 | + 'name' => last(explode("/", $path)), |
|
65 | + ]); |
|
66 | + |
|
67 | + return $this->client->uploadData($contents, $uploadPolicy); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Write a new file using a stream. |
|
72 | + * |
|
73 | + * @param string $path |
|
74 | + * @param resource $resource |
|
75 | + * @param Config $config Config object |
|
76 | + * |
|
77 | + * @return array|false false on failure file meta data on success |
|
78 | + */ |
|
79 | + public function writeStream($path, $resource, Config $config) |
|
80 | + { |
|
81 | + $contents = ''; |
|
82 | + |
|
83 | + while (!feof($resource)) { |
|
84 | + $contents .= fread($resource, 1024); |
|
85 | + } |
|
86 | + |
|
87 | + $response = $this->write($path, $contents, $config); |
|
88 | + |
|
89 | + if (false === $response) { |
|
90 | + return $response; |
|
91 | + } |
|
92 | + |
|
93 | + return compact('path'); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Update a file. |
|
98 | + * |
|
99 | + * @param string $path |
|
100 | + * @param string $contents |
|
101 | + * @param Config $config Config object |
|
102 | + * |
|
103 | + * @return array|false false on failure file meta data on success |
|
104 | + */ |
|
105 | + public function update($path, $contents, Config $config) |
|
106 | + { |
|
107 | + $this->delete($path); |
|
108 | + |
|
109 | + return $this->write($path, $contents, $config); |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Update a file using a stream. |
|
114 | + * |
|
115 | + * @param string $path |
|
116 | + * @param resource $resource |
|
117 | + * @param Config $config Config object |
|
118 | + * |
|
119 | + * @return array|false false on failure file meta data on success |
|
120 | + */ |
|
121 | + public function updateStream($path, $resource, Config $config) |
|
122 | + { |
|
123 | + $this->delete($path); |
|
124 | + |
|
125 | + return $this->writeStream($path, $resource, $config); |
|
126 | + } |
|
127 | + |
|
128 | + public function put($path, $contents, Config $config) |
|
129 | + { |
|
130 | + return $this->write($path, $contents, $config); |
|
131 | + } |
|
132 | + |
|
133 | + public function putStream($path, $resource, Config $config) |
|
134 | + { |
|
135 | + return $this->write($path, $resource, $config); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Rename a file. |
|
140 | + * |
|
141 | + * @param string $path |
|
142 | + * @param string $newpath |
|
143 | + * |
|
144 | + * @return bool |
|
145 | + */ |
|
146 | + public function rename($path, $newpath) |
|
147 | + { |
|
148 | + return $this->client->renameFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)), preg_replace('/^\./', '', dirname($newpath)), last(explode("/", $newpath))); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * Copy a file. |
|
153 | + * |
|
154 | + * @param string $path |
|
155 | + * @param string $newpath |
|
156 | + * |
|
157 | + * @return bool |
|
158 | + */ |
|
159 | + public function copy($path, $newpath) |
|
160 | + { |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Delete a file. |
|
165 | + * |
|
166 | + * @param string $path |
|
167 | + * |
|
168 | + * @return bool |
|
169 | + */ |
|
170 | + public function delete($path) |
|
171 | + { |
|
172 | + return $this->client->deleteFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path))); |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Delete a directory. |
|
177 | + * |
|
178 | + * @param string $dirname |
|
179 | + * |
|
180 | + * @return bool |
|
181 | + */ |
|
182 | + public function deleteDir($dirname) |
|
183 | + { |
|
184 | + return $this->client->deleteDir($this->namespace, $dirname); |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * Create a directory. |
|
189 | + * |
|
190 | + * @param string $dirname directory name |
|
191 | + * @param Config $config |
|
192 | + * |
|
193 | + * @return array|false |
|
194 | + */ |
|
195 | + public function createDir($dirname, Config $config) |
|
196 | + { |
|
197 | + return $this->client->createDir($this->namespace, $dirname); |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Check whether a file exists. |
|
202 | + * |
|
203 | + * @param string $path |
|
204 | + * |
|
205 | + * @return array|bool|null |
|
206 | + */ |
|
207 | + public function has($path) |
|
208 | + { |
|
209 | + if (Str::endsWith($path, "/")) { |
|
210 | + return $this->client->existsFolder($this->namespace, preg_replace('/^\./', '', dirname($path))); |
|
211 | + } else { |
|
212 | + return $this->client->existsFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path))); |
|
213 | + } |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * Read a file. |
|
219 | + * |
|
220 | + * @param string $path |
|
221 | + * |
|
222 | + * @return array|false |
|
223 | + */ |
|
224 | + public function read($path) |
|
225 | + { |
|
226 | + $contents = file_get_contents($this->getUrl($path)); |
|
227 | + return compact('contents', 'path'); |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Read a file as a stream. |
|
232 | + * |
|
233 | + * @param string $path |
|
234 | + * |
|
235 | + * @return array|false |
|
236 | + */ |
|
237 | + public function readStream($path) |
|
238 | + { |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * List contents of a directory. |
|
243 | + * |
|
244 | + * @param string $directory |
|
245 | + * @param bool $recursive |
|
246 | + * |
|
247 | + * @return array |
|
248 | + */ |
|
249 | + public function listContents($directory = '', $recursive = false) |
|
250 | + { |
|
251 | + return $this->client->listFiles($this->namespace, $directory, 1, 1000); |
|
252 | + } |
|
253 | + |
|
254 | + /** |
|
255 | + * Get all the meta data of a file or directory. |
|
256 | + * |
|
257 | + * @param string $path |
|
258 | + * |
|
259 | + * @return array|false |
|
260 | + */ |
|
261 | + public function getMetadata($path) |
|
262 | + { |
|
263 | + return $this->client->getFileInfo($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path))); |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * Get the size of a file. |
|
268 | + * |
|
269 | + * @param string $path |
|
270 | + * |
|
271 | + * @return array|false |
|
272 | + */ |
|
273 | + public function getSize($path) |
|
274 | + { |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * Fetch url to bucket. |
|
280 | + * |
|
281 | + * @param string $path |
|
282 | + * @param string $url |
|
283 | + * |
|
284 | + * @return array|false |
|
285 | + */ |
|
286 | + public function fetch($path, $url) |
|
287 | + { |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * Get private file download url. |
|
292 | + * |
|
293 | + * @param string $path |
|
294 | + * @param int $expires |
|
295 | + * |
|
296 | + * @return string |
|
297 | + */ |
|
298 | + public function privateDownloadUrl($path, $expires = 3600) |
|
299 | + { |
|
300 | + } |
|
301 | + |
|
302 | + /** |
|
303 | + * Refresh file cache. |
|
304 | + * |
|
305 | + * @param string|array $path |
|
306 | + * |
|
307 | + * @return array |
|
308 | + */ |
|
309 | + public function refresh($path) |
|
310 | + { |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + /** |
|
315 | + * Get the mime-type of a file. |
|
316 | + * |
|
317 | + * @param string $path |
|
318 | + * |
|
319 | + * @return array|false |
|
320 | + */ |
|
321 | + public function getMimeType($path) |
|
322 | + { |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * Get the timestamp of a file. |
|
328 | + * |
|
329 | + * @param string $path |
|
330 | + * |
|
331 | + * @return array|false |
|
332 | + */ |
|
333 | + public function getTimestamp($path) |
|
334 | + { |
|
335 | + } |
|
336 | + |
|
337 | + /** |
|
338 | + * Get the upload token. |
|
339 | + * |
|
340 | + * @param string|null $key |
|
341 | + * @param int $ttl |
|
342 | + * @param string|null $policy |
|
343 | + * @param string|null $strictPolice |
|
344 | + * |
|
345 | + * @return string |
|
346 | + */ |
|
347 | + public function getUploadToken($option = null) |
|
348 | + { |
|
349 | + if ($option === null) { |
|
350 | + $option = ['name' => null, 'ttl' => 3600, ]; |
|
351 | + } elseif (!isset($option['ttl']) || !$option['ttl']) { |
|
352 | + $option['ttl'] = 3600; |
|
353 | + } |
|
354 | + |
|
355 | + return $this->client->getUploadToken(collect([ |
|
356 | + 'expiration' => Carbon::now()->addSeconds($option['ttl'])->timestamp * 1000, |
|
357 | + 'insertOnly' => Conf::INSERT_ONLY_TRUE |
|
358 | + ])->merge(collect($option)->except(['ttl',]))); |
|
359 | + } |
|
360 | + |
|
361 | + /** |
|
362 | + * @param array $stats |
|
363 | + * |
|
364 | + * @return array |
|
365 | + */ |
|
366 | + protected function normalizeFileInfo(array $stats) |
|
367 | + { |
|
368 | + return [ |
|
369 | + 'type' => 'file', |
|
370 | + 'path' => $stats['key'], |
|
371 | + 'timestamp' => floor($stats['putTime'] / 10000000), |
|
372 | + 'size' => $stats['fsize'], |
|
373 | + ]; |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * Get resource url. |
|
378 | + * |
|
379 | + * @param string $path |
|
380 | + * |
|
381 | + * @return string |
|
382 | + */ |
|
383 | + public function getUrl($path) |
|
384 | + { |
|
385 | + return $this->normalizeHost($this->domain) . ltrim($path, '/'); |
|
386 | + } |
|
387 | + |
|
388 | + /** |
|
389 | + * @param string $domain |
|
390 | + * |
|
391 | + * @return string |
|
392 | + */ |
|
393 | + protected function normalizeHost($domain) |
|
394 | + { |
|
395 | + if (0 !== stripos($domain, 'https://') && 0 !== stripos($domain, 'http://')) { |
|
396 | + $domain = "http://{$domain}"; |
|
397 | + } |
|
398 | + return rtrim($domain, '/') . '/'; |
|
399 | + } |
|
400 | 400 | } |
@@ -5,47 +5,47 @@ |
||
5 | 5 | |
6 | 6 | class UploadPolicy |
7 | 7 | { |
8 | - /*如下属性是必须的[The following attributes are required]*/ |
|
9 | - public $namespace; // 多媒体服务的空间名[media namespace name] |
|
10 | - public $bucket; // OSS的空间名[media bucket name] |
|
11 | - public $insertOnly; // 是否可覆盖[upload mode. it's not allowd uploading the same name files] |
|
12 | - public $expiration; // 过期时间[expiration time, unix time, in milliseconds] |
|
8 | + /*如下属性是必须的[The following attributes are required]*/ |
|
9 | + public $namespace; // 多媒体服务的空间名[media namespace name] |
|
10 | + public $bucket; // OSS的空间名[media bucket name] |
|
11 | + public $insertOnly; // 是否可覆盖[upload mode. it's not allowd uploading the same name files] |
|
12 | + public $expiration; // 过期时间[expiration time, unix time, in milliseconds] |
|
13 | 13 | |
14 | - /*如下属性是可选的[The following attributes are optional]*/ |
|
15 | - public $detectMime = Conf::DETECT_MIME_TRUE; // 是否进行类型检测[is auto detecte media file mime type, default is true] |
|
16 | - public $dir; // 路径[media file dir, magic vars and custom vars are supported] |
|
17 | - public $name; // 上传到服务端的文件名[media file name, magic vars and custom vars are supported] |
|
18 | - public $sizeLimit; // 文件大小限制[upload size limited, in bytes] |
|
19 | - public $mimeLimit; // 文件类型限制[upload mime type limited] |
|
20 | - public $callbackUrl; // 回调URL [callback urls, ip address is recommended] |
|
21 | - public $callbackHost; // 回调时Host [callback host] |
|
22 | - public $callbackBody; // 回调时Body [callback body, magic vars and custom vars are supported] |
|
23 | - public $callbackBodyType; // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8'] |
|
24 | - public $returnUrl; // 上传完成之后,303跳转的Url [return url, when return code is 303] |
|
25 | - public $returnBody; // 上传完成返回体 [return body, magic vars and custom vars are supported] |
|
26 | - public $mediaEncode; // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string] |
|
14 | + /*如下属性是可选的[The following attributes are optional]*/ |
|
15 | + public $detectMime = Conf::DETECT_MIME_TRUE; // 是否进行类型检测[is auto detecte media file mime type, default is true] |
|
16 | + public $dir; // 路径[media file dir, magic vars and custom vars are supported] |
|
17 | + public $name; // 上传到服务端的文件名[media file name, magic vars and custom vars are supported] |
|
18 | + public $sizeLimit; // 文件大小限制[upload size limited, in bytes] |
|
19 | + public $mimeLimit; // 文件类型限制[upload mime type limited] |
|
20 | + public $callbackUrl; // 回调URL [callback urls, ip address is recommended] |
|
21 | + public $callbackHost; // 回调时Host [callback host] |
|
22 | + public $callbackBody; // 回调时Body [callback body, magic vars and custom vars are supported] |
|
23 | + public $callbackBodyType; // 回调时Body类型 [callback body type, default is 'application/x-www-form-urlencoded; charset=utf-8'] |
|
24 | + public $returnUrl; // 上传完成之后,303跳转的Url [return url, when return code is 303] |
|
25 | + public $returnBody; // 上传完成返回体 [return body, magic vars and custom vars are supported] |
|
26 | + public $mediaEncode; // 上传音视频时,可以指定转码策略[media encode policy after upload task has been completed. it's json string] |
|
27 | 27 | |
28 | - public function __construct($option) |
|
29 | - { |
|
30 | - if (!isset($option['expiration']) || !$option['expiration']) { |
|
31 | - $option['expiration'] = -1; |
|
32 | - } |
|
28 | + public function __construct($option) |
|
29 | + { |
|
30 | + if (!isset($option['expiration']) || !$option['expiration']) { |
|
31 | + $option['expiration'] = -1; |
|
32 | + } |
|
33 | 33 | |
34 | - foreach ($option as $attribute => $value) { |
|
35 | - $this->{$attribute} = $value; |
|
36 | - } |
|
37 | - } |
|
34 | + foreach ($option as $attribute => $value) { |
|
35 | + $this->{$attribute} = $value; |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - public function toArray() |
|
40 | - { |
|
41 | - return (array) $this; |
|
42 | - $array = []; |
|
43 | - foreach ($this as $attribute => $value) { |
|
44 | - if ($value !== null) { |
|
45 | - $array[$attribute] = $value; |
|
46 | - } |
|
47 | - } |
|
39 | + public function toArray() |
|
40 | + { |
|
41 | + return (array) $this; |
|
42 | + $array = []; |
|
43 | + foreach ($this as $attribute => $value) { |
|
44 | + if ($value !== null) { |
|
45 | + $array[$attribute] = $value; |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - return $array; |
|
50 | - } |
|
49 | + return $array; |
|
50 | + } |
|
51 | 51 | } |
@@ -3,39 +3,39 @@ |
||
3 | 3 | |
4 | 4 | class Conf |
5 | 5 | { |
6 | - const CHARSET = "UTF-8"; |
|
7 | - const SDK_VERSION = '2.0.3'; |
|
6 | + const CHARSET = "UTF-8"; |
|
7 | + const SDK_VERSION = '2.0.3'; |
|
8 | 8 | |
9 | - const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com"; //文件上传的地址 |
|
10 | - const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com"; //服务管理的地址 |
|
11 | - const MANAGE_API_VERSION = "3.0"; //资源管理接口版本 |
|
12 | - const SCAN_PORN_VERSION = "3.1"; //黄图扫描接口版本 |
|
13 | - const MEDIA_ENCODE_VERSION = "3.0"; //媒体转码接口版本 |
|
9 | + const UPLOAD_HOST_MEDIA = "https://upload.media.aliyun.com"; //文件上传的地址 |
|
10 | + const MANAGE_HOST_MEDIA = "https://rs.media.aliyun.com"; //服务管理的地址 |
|
11 | + const MANAGE_API_VERSION = "3.0"; //资源管理接口版本 |
|
12 | + const SCAN_PORN_VERSION = "3.1"; //黄图扫描接口版本 |
|
13 | + const MEDIA_ENCODE_VERSION = "3.0"; //媒体转码接口版本 |
|
14 | 14 | |
15 | - const UPLOAD_API_UPLOAD = "/api/proxy/upload"; |
|
16 | - const UPLOAD_API_BLOCK_INIT = "/api/proxy/blockInit"; |
|
17 | - const UPLOAD_API_BLOCK_UPLOAD = "/api/proxy/blockUpload"; |
|
18 | - const UPLOAD_API_BLOCK_COMPLETE = "/api/proxy/blockComplete"; |
|
19 | - const UPLOAD_API_BLOCK_CANCEL = "/api/proxy/blockCancel"; |
|
15 | + const UPLOAD_API_UPLOAD = "/api/proxy/upload"; |
|
16 | + const UPLOAD_API_BLOCK_INIT = "/api/proxy/blockInit"; |
|
17 | + const UPLOAD_API_BLOCK_UPLOAD = "/api/proxy/blockUpload"; |
|
18 | + const UPLOAD_API_BLOCK_COMPLETE = "/api/proxy/blockComplete"; |
|
19 | + const UPLOAD_API_BLOCK_CANCEL = "/api/proxy/blockCancel"; |
|
20 | 20 | |
21 | - const TYPE_TOP = "TOP"; |
|
22 | - const TYPE_CLOUD = "CLOUD"; |
|
21 | + const TYPE_TOP = "TOP"; |
|
22 | + const TYPE_CLOUD = "CLOUD"; |
|
23 | 23 | |
24 | - const DETECT_MIME_TRUE = 1; //检测MimeType |
|
25 | - const DETECT_MIME_NONE = 0; //不检测MimeType |
|
26 | - const INSERT_ONLY_TRUE = 1; //文件上传不可覆盖 |
|
27 | - const INSERT_ONLY_NONE = 0; //文件上传可覆盖 |
|
24 | + const DETECT_MIME_TRUE = 1; //检测MimeType |
|
25 | + const DETECT_MIME_NONE = 0; //不检测MimeType |
|
26 | + const INSERT_ONLY_TRUE = 1; //文件上传不可覆盖 |
|
27 | + const INSERT_ONLY_NONE = 0; //文件上传可覆盖 |
|
28 | 28 | |
29 | - const MIN_OBJ_SIZE = 1; //1024*100; |
|
30 | - const HTTP_TIMEOUT = 30; //http的超时时间:30s |
|
31 | - const HTTP_RETRY = 1; //http失败后重试:1 |
|
29 | + const MIN_OBJ_SIZE = 1; //1024*100; |
|
30 | + const HTTP_TIMEOUT = 30; //http的超时时间:30s |
|
31 | + const HTTP_RETRY = 1; //http失败后重试:1 |
|
32 | 32 | |
33 | - const BLOCK_MIN_SIZE = 102400; //文件分片最小值:1024*100; 100K |
|
34 | - const BLOCK_DEFF_SIZE = 209715200; //文件分片默认值:1024*1024*2; 2M |
|
35 | - const BLOCK_MAX_SIZE = 104857600; //文件分片最大值:1024*1024*10; 10M |
|
33 | + const BLOCK_MIN_SIZE = 102400; //文件分片最小值:1024*100; 100K |
|
34 | + const BLOCK_DEFF_SIZE = 209715200; //文件分片默认值:1024*1024*2; 2M |
|
35 | + const BLOCK_MAX_SIZE = 104857600; //文件分片最大值:1024*1024*10; 10M |
|
36 | 36 | |
37 | - const CURL_ERR_LOG = "curl_error.log"; //curl请求时的错误日志信息 |
|
37 | + const CURL_ERR_LOG = "curl_error.log"; //curl请求时的错误日志信息 |
|
38 | 38 | |
39 | - const RUN_LEVEL_RELEASE = 1; //release级别 |
|
40 | - const RUN_LEVEL_DEBUG = 2; //debug级别 |
|
39 | + const RUN_LEVEL_RELEASE = 1; //release级别 |
|
40 | + const RUN_LEVEL_DEBUG = 2; //debug级别 |
|
41 | 41 | } |
@@ -12,238 +12,238 @@ |
||
12 | 12 | |
13 | 13 | class AlibabaImage |
14 | 14 | { |
15 | - private $upload_client; |
|
16 | - private $manage_client; |
|
17 | - private $ak; |
|
18 | - private $sk; |
|
19 | - private $namespace; |
|
20 | - private $type; // "TOP"和"CLOUD"两种模式 |
|
21 | - |
|
22 | - public static $run_level = Conf::RUN_LEVEL_RELEASE; //设置SDK运行级别 |
|
23 | - |
|
24 | - /** |
|
25 | - * 构造函数 |
|
26 | - * |
|
27 | - * @param string $ak 云存储公钥 |
|
28 | - * @param string $sk 云存储私钥 |
|
29 | - * @param string $type 可选,兼容TOP与tea云的 ak/sk |
|
30 | - * @throws \Exception |
|
31 | - */ |
|
32 | - public function __construct($ak, $sk, $namespace, $type = Conf::TYPE_TOP) |
|
33 | - { |
|
34 | - $this->ak = $ak; |
|
35 | - $this->sk = $sk; |
|
36 | - $this->namespace = $namespace; |
|
37 | - $this->type = $type; |
|
38 | - $this->upload_client = new UploadClient($ak, $sk, $type); |
|
39 | - $this->manage_client = new ManageClient($ak, $sk, $type); |
|
40 | - } |
|
41 | - |
|
42 | - public function getUploadToken($option) |
|
43 | - { |
|
44 | - if (!isset($option['name']) || !$option['name']) { |
|
45 | - $option['name'] = '${uuid}.${ext}'; |
|
46 | - } |
|
47 | - if ($option['name']) { |
|
48 | - $option['dir'] = preg_replace('/^\./', '', dirname($option['name'])); |
|
49 | - $option['name'] = last(explode("/", $option['name'])); |
|
50 | - } |
|
51 | - $option['namespace'] = $this->namespace; |
|
52 | - |
|
53 | - $policy = new UploadPolicy($option); |
|
54 | - |
|
55 | - return $this->upload_client->getUploadToken($policy); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * 直接上传文件,适合文件比较小的情况 |
|
60 | - */ |
|
61 | - public function upload($filePath, UploadPolicy $uploadPolicy, UploadOption $uploadOption = null) |
|
62 | - { |
|
63 | - return $this->upload_client->upload($filePath, $uploadPolicy, $uploadOption); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * 直接上传文件数据,适合数据量比较小的情况 |
|
68 | - */ |
|
69 | - public function uploadData($data, UploadPolicy $uploadPolicy, UploadOption $uploadOption = null) |
|
70 | - { |
|
71 | - return $this->upload_client->uploadData($data, $uploadPolicy, $uploadOption); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * 创建分片上传任务,指定待上传的文件。即初始化分片上传 |
|
76 | - */ |
|
77 | - public function multipartInit($filePath, UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
78 | - { |
|
79 | - return $this->upload_client->multipartInit($filePath, $uploadPolicy, $uploadOption); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * 创建分片上传任务,指定初始化分片任务的数据,即第一块数据 |
|
84 | - */ |
|
85 | - public function multipartInitByData($data, UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
86 | - { |
|
87 | - return $this->upload_client->multipartInitByData($data, $uploadPolicy, $uploadOption); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * 分片上传,指定待上传的文件。需要指定UploadOption中文件块编号 |
|
92 | - */ |
|
93 | - public function multipartUpload($filePath, UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
94 | - { |
|
95 | - return $this->upload_client->multipartUpload($filePath, $uploadPolicy, $uploadOption); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * 分片上传,指定待上传的数据。需要指定UploadOption中文件块编号 |
|
100 | - */ |
|
101 | - public function multipartUploadByData($blockData, UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
102 | - { |
|
103 | - return $this->upload_client->multipartUploadByData($blockData, $uploadPolicy, $uploadOption); |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * 完成分片上传任务。需要指定UploadOption中整个文件的md5值 |
|
108 | - */ |
|
109 | - public function multipartComplete(UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
110 | - { |
|
111 | - return $this->upload_client->multipartComplete($uploadPolicy, $uploadOption); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * 取消分片上传任务。需要保证UploadOption中有分片任务的uploadId和id |
|
116 | - */ |
|
117 | - public function multipartCancel(UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
118 | - { |
|
119 | - return $this->upload_client->multipartCancel($uploadPolicy, $uploadOption); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * 查看文件是否存在 |
|
124 | - */ |
|
125 | - public function existsFile($namespace, $dir, $filename) |
|
126 | - { |
|
127 | - return $this->manage_client->existsFile($namespace, $dir, $filename); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * 获取文件的元信息(meta信息) |
|
132 | - */ |
|
133 | - public function getFileInfo($namespace, $dir, $filename) |
|
134 | - { |
|
135 | - return $this->manage_client->getFileInfo($namespace, $dir, $filename); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * 重命名文件 |
|
140 | - */ |
|
141 | - public function renameFile($namespace, $dir, $filename, $newDir, $newName) |
|
142 | - { |
|
143 | - return $this->manage_client->renameFile($namespace, $dir, $filename, $newDir, $newName); |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * 获取指定目录下的文件列表。dir为空,表示根目录。page指定页数,pageSize指定每页显示数量 |
|
148 | - */ |
|
149 | - public function listFiles($namespace, $dir, $page = 1, $pageSize = 100) |
|
150 | - { |
|
151 | - return $this->manage_client->listFiles($namespace, $dir, $page, $pageSize); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * 删除文件 |
|
156 | - */ |
|
157 | - public function deleteFile($namespace, $dir, $filename) |
|
158 | - { |
|
159 | - return $this->manage_client->deleteFile($namespace, $dir, $filename); |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * 查看文件夹是否存在 |
|
164 | - */ |
|
165 | - public function existsFolder($namespace, $dir) |
|
166 | - { |
|
167 | - return $this->manage_client->existsFolder($namespace, $dir); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * 创建文件夹 |
|
172 | - */ |
|
173 | - public function createDir($namespace, $dir) |
|
174 | - { |
|
175 | - return $this->manage_client->createDir($namespace, $dir); |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * 获取子文件夹列表。dir为空,表示根目录。page指定页数,pageSize指定每页显示数量 |
|
180 | - */ |
|
181 | - public function listDirs($namespace, $dir, $page = 1, $pageSize = 100) |
|
182 | - { |
|
183 | - return $this->manage_client->listDirs($namespace, $dir, $page, $pageSize); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * 删除文件夹 |
|
188 | - */ |
|
189 | - public function deleteDir($namespace, $dir) |
|
190 | - { |
|
191 | - return $this->manage_client->deleteDir($namespace, $dir); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * 黄图扫描接口 |
|
196 | - */ |
|
197 | - public function scanPorn(ManageOption $resInfos) |
|
198 | - { |
|
199 | - return $this->manage_client->scanPorn($resInfos); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * 鉴黄反馈feedback接口 |
|
204 | - */ |
|
205 | - public function pornFeedback(ManageOption $pornFbInfos) |
|
206 | - { |
|
207 | - return $this->manage_client->pornFeedback($pornFbInfos); |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * 多媒体转码接口 |
|
212 | - */ |
|
213 | - public function mediaEncode(MediaEncodeOption $encodeOption) |
|
214 | - { |
|
215 | - return $this->manage_client->mediaEncode($encodeOption); |
|
216 | - } |
|
217 | - |
|
218 | - /** |
|
219 | - * 多媒体转码任务查询接口 |
|
220 | - */ |
|
221 | - public function mediaEncodeQuery($taskId) |
|
222 | - { |
|
223 | - return $this->manage_client->mediaEncodeQuery($taskId); |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * 视频截图接口 |
|
228 | - */ |
|
229 | - public function videoSnapshot(SnapShotOption $snapshotOption) |
|
230 | - { |
|
231 | - return $this->manage_client->videoSnapshot($snapshotOption); |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * 视频截图结果查询接口 |
|
236 | - */ |
|
237 | - public function vSnapshotQuery($taskId) |
|
238 | - { |
|
239 | - return $this->manage_client->vSnapshotQuery($taskId); |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * 广告图扫描接口(beta) |
|
244 | - */ |
|
245 | - public function scanAdvertising(ManageOption $resInfos) |
|
246 | - { |
|
247 | - return $this->manage_client->scanAdvertising($resInfos); |
|
248 | - } |
|
15 | + private $upload_client; |
|
16 | + private $manage_client; |
|
17 | + private $ak; |
|
18 | + private $sk; |
|
19 | + private $namespace; |
|
20 | + private $type; // "TOP"和"CLOUD"两种模式 |
|
21 | + |
|
22 | + public static $run_level = Conf::RUN_LEVEL_RELEASE; //设置SDK运行级别 |
|
23 | + |
|
24 | + /** |
|
25 | + * 构造函数 |
|
26 | + * |
|
27 | + * @param string $ak 云存储公钥 |
|
28 | + * @param string $sk 云存储私钥 |
|
29 | + * @param string $type 可选,兼容TOP与tea云的 ak/sk |
|
30 | + * @throws \Exception |
|
31 | + */ |
|
32 | + public function __construct($ak, $sk, $namespace, $type = Conf::TYPE_TOP) |
|
33 | + { |
|
34 | + $this->ak = $ak; |
|
35 | + $this->sk = $sk; |
|
36 | + $this->namespace = $namespace; |
|
37 | + $this->type = $type; |
|
38 | + $this->upload_client = new UploadClient($ak, $sk, $type); |
|
39 | + $this->manage_client = new ManageClient($ak, $sk, $type); |
|
40 | + } |
|
41 | + |
|
42 | + public function getUploadToken($option) |
|
43 | + { |
|
44 | + if (!isset($option['name']) || !$option['name']) { |
|
45 | + $option['name'] = '${uuid}.${ext}'; |
|
46 | + } |
|
47 | + if ($option['name']) { |
|
48 | + $option['dir'] = preg_replace('/^\./', '', dirname($option['name'])); |
|
49 | + $option['name'] = last(explode("/", $option['name'])); |
|
50 | + } |
|
51 | + $option['namespace'] = $this->namespace; |
|
52 | + |
|
53 | + $policy = new UploadPolicy($option); |
|
54 | + |
|
55 | + return $this->upload_client->getUploadToken($policy); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * 直接上传文件,适合文件比较小的情况 |
|
60 | + */ |
|
61 | + public function upload($filePath, UploadPolicy $uploadPolicy, UploadOption $uploadOption = null) |
|
62 | + { |
|
63 | + return $this->upload_client->upload($filePath, $uploadPolicy, $uploadOption); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * 直接上传文件数据,适合数据量比较小的情况 |
|
68 | + */ |
|
69 | + public function uploadData($data, UploadPolicy $uploadPolicy, UploadOption $uploadOption = null) |
|
70 | + { |
|
71 | + return $this->upload_client->uploadData($data, $uploadPolicy, $uploadOption); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * 创建分片上传任务,指定待上传的文件。即初始化分片上传 |
|
76 | + */ |
|
77 | + public function multipartInit($filePath, UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
78 | + { |
|
79 | + return $this->upload_client->multipartInit($filePath, $uploadPolicy, $uploadOption); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * 创建分片上传任务,指定初始化分片任务的数据,即第一块数据 |
|
84 | + */ |
|
85 | + public function multipartInitByData($data, UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
86 | + { |
|
87 | + return $this->upload_client->multipartInitByData($data, $uploadPolicy, $uploadOption); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * 分片上传,指定待上传的文件。需要指定UploadOption中文件块编号 |
|
92 | + */ |
|
93 | + public function multipartUpload($filePath, UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
94 | + { |
|
95 | + return $this->upload_client->multipartUpload($filePath, $uploadPolicy, $uploadOption); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * 分片上传,指定待上传的数据。需要指定UploadOption中文件块编号 |
|
100 | + */ |
|
101 | + public function multipartUploadByData($blockData, UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
102 | + { |
|
103 | + return $this->upload_client->multipartUploadByData($blockData, $uploadPolicy, $uploadOption); |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * 完成分片上传任务。需要指定UploadOption中整个文件的md5值 |
|
108 | + */ |
|
109 | + public function multipartComplete(UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
110 | + { |
|
111 | + return $this->upload_client->multipartComplete($uploadPolicy, $uploadOption); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * 取消分片上传任务。需要保证UploadOption中有分片任务的uploadId和id |
|
116 | + */ |
|
117 | + public function multipartCancel(UploadPolicy $uploadPolicy, UploadOption $uploadOption) |
|
118 | + { |
|
119 | + return $this->upload_client->multipartCancel($uploadPolicy, $uploadOption); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * 查看文件是否存在 |
|
124 | + */ |
|
125 | + public function existsFile($namespace, $dir, $filename) |
|
126 | + { |
|
127 | + return $this->manage_client->existsFile($namespace, $dir, $filename); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * 获取文件的元信息(meta信息) |
|
132 | + */ |
|
133 | + public function getFileInfo($namespace, $dir, $filename) |
|
134 | + { |
|
135 | + return $this->manage_client->getFileInfo($namespace, $dir, $filename); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * 重命名文件 |
|
140 | + */ |
|
141 | + public function renameFile($namespace, $dir, $filename, $newDir, $newName) |
|
142 | + { |
|
143 | + return $this->manage_client->renameFile($namespace, $dir, $filename, $newDir, $newName); |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * 获取指定目录下的文件列表。dir为空,表示根目录。page指定页数,pageSize指定每页显示数量 |
|
148 | + */ |
|
149 | + public function listFiles($namespace, $dir, $page = 1, $pageSize = 100) |
|
150 | + { |
|
151 | + return $this->manage_client->listFiles($namespace, $dir, $page, $pageSize); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * 删除文件 |
|
156 | + */ |
|
157 | + public function deleteFile($namespace, $dir, $filename) |
|
158 | + { |
|
159 | + return $this->manage_client->deleteFile($namespace, $dir, $filename); |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * 查看文件夹是否存在 |
|
164 | + */ |
|
165 | + public function existsFolder($namespace, $dir) |
|
166 | + { |
|
167 | + return $this->manage_client->existsFolder($namespace, $dir); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * 创建文件夹 |
|
172 | + */ |
|
173 | + public function createDir($namespace, $dir) |
|
174 | + { |
|
175 | + return $this->manage_client->createDir($namespace, $dir); |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * 获取子文件夹列表。dir为空,表示根目录。page指定页数,pageSize指定每页显示数量 |
|
180 | + */ |
|
181 | + public function listDirs($namespace, $dir, $page = 1, $pageSize = 100) |
|
182 | + { |
|
183 | + return $this->manage_client->listDirs($namespace, $dir, $page, $pageSize); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * 删除文件夹 |
|
188 | + */ |
|
189 | + public function deleteDir($namespace, $dir) |
|
190 | + { |
|
191 | + return $this->manage_client->deleteDir($namespace, $dir); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * 黄图扫描接口 |
|
196 | + */ |
|
197 | + public function scanPorn(ManageOption $resInfos) |
|
198 | + { |
|
199 | + return $this->manage_client->scanPorn($resInfos); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * 鉴黄反馈feedback接口 |
|
204 | + */ |
|
205 | + public function pornFeedback(ManageOption $pornFbInfos) |
|
206 | + { |
|
207 | + return $this->manage_client->pornFeedback($pornFbInfos); |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * 多媒体转码接口 |
|
212 | + */ |
|
213 | + public function mediaEncode(MediaEncodeOption $encodeOption) |
|
214 | + { |
|
215 | + return $this->manage_client->mediaEncode($encodeOption); |
|
216 | + } |
|
217 | + |
|
218 | + /** |
|
219 | + * 多媒体转码任务查询接口 |
|
220 | + */ |
|
221 | + public function mediaEncodeQuery($taskId) |
|
222 | + { |
|
223 | + return $this->manage_client->mediaEncodeQuery($taskId); |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * 视频截图接口 |
|
228 | + */ |
|
229 | + public function videoSnapshot(SnapShotOption $snapshotOption) |
|
230 | + { |
|
231 | + return $this->manage_client->videoSnapshot($snapshotOption); |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * 视频截图结果查询接口 |
|
236 | + */ |
|
237 | + public function vSnapshotQuery($taskId) |
|
238 | + { |
|
239 | + return $this->manage_client->vSnapshotQuery($taskId); |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * 广告图扫描接口(beta) |
|
244 | + */ |
|
245 | + public function scanAdvertising(ManageOption $resInfos) |
|
246 | + { |
|
247 | + return $this->manage_client->scanAdvertising($resInfos); |
|
248 | + } |
|
249 | 249 | } |
@@ -4,93 +4,93 @@ |
||
4 | 4 | /**文件资源类*/ |
5 | 5 | class ResourceInfo |
6 | 6 | { |
7 | - /* 以下属性是资源ID所需的属性*/ |
|
8 | - protected $namespace; //空间名,必须 |
|
9 | - protected $dir; //路径 |
|
10 | - protected $name; //文件名信息 |
|
11 | - /* 以下属性是资源ID所需的属性*/ |
|
12 | - /** |
|
13 | - * ResourceOption的构造函数 |
|
14 | - */ |
|
15 | - public function __construct($namespace, $dir = null, $name = null) |
|
16 | - { |
|
17 | - $this->namespace = $namespace; |
|
18 | - $this->dir = $dir; |
|
19 | - $this->name = $name; |
|
20 | - } |
|
21 | - /**检测资源ID的是否合法。$dirState表示是否检测dir,$nameState表示是否检测filename<p> |
|
7 | + /* 以下属性是资源ID所需的属性*/ |
|
8 | + protected $namespace; //空间名,必须 |
|
9 | + protected $dir; //路径 |
|
10 | + protected $name; //文件名信息 |
|
11 | + /* 以下属性是资源ID所需的属性*/ |
|
12 | + /** |
|
13 | + * ResourceOption的构造函数 |
|
14 | + */ |
|
15 | + public function __construct($namespace, $dir = null, $name = null) |
|
16 | + { |
|
17 | + $this->namespace = $namespace; |
|
18 | + $this->dir = $dir; |
|
19 | + $this->name = $name; |
|
20 | + } |
|
21 | + /**检测资源ID的是否合法。$dirState表示是否检测dir,$nameState表示是否检测filename<p> |
|
22 | 22 | * 返回格式{$isValid, $message}*/ |
23 | - public function checkResourceInfo($dirState = false, $nameState = false) |
|
24 | - { |
|
25 | - if (empty($this->namespace)) { |
|
26 | - return array(false, "namespace is empty.[{$this->toString()}]"); // 判断是否设置空间名 |
|
27 | - } else { |
|
28 | - return $this->checkFileInfo($dirState, $nameState); // 判断dir和name的合法性 |
|
29 | - } |
|
30 | - } |
|
31 | - /**检测文件信息是否合法。$dirState表示是否检测dir,$nameState表示是否检测filename<p> |
|
23 | + public function checkResourceInfo($dirState = false, $nameState = false) |
|
24 | + { |
|
25 | + if (empty($this->namespace)) { |
|
26 | + return array(false, "namespace is empty.[{$this->toString()}]"); // 判断是否设置空间名 |
|
27 | + } else { |
|
28 | + return $this->checkFileInfo($dirState, $nameState); // 判断dir和name的合法性 |
|
29 | + } |
|
30 | + } |
|
31 | + /**检测文件信息是否合法。$dirState表示是否检测dir,$nameState表示是否检测filename<p> |
|
32 | 32 | * 返回格式{$isValid, $message}*/ |
33 | - public function checkFileInfo($dirState = false, $nameState = false) |
|
34 | - { |
|
35 | - if ($nameState && empty($this->name)) { |
|
36 | - return array(false, "file's name is empty.[{$this->toString()}]"); // 1:若需要进行文件名name检测,则判断文件名是否为空 |
|
37 | - } |
|
38 | - if ($dirState) { |
|
39 | - if (empty($this->dir)) { |
|
40 | - $this->dir = '/'; // 2:判断路径是否为空,若为空,则默认为根目录'/' |
|
41 | - } elseif (strpos($this->dir, '/') !== 0) { |
|
42 | - $this->dir = '/' . $this->dir; // 3:判断路径是否以'/'开头,若不是,则添加'/' |
|
43 | - } |
|
44 | - } |
|
45 | - return array(true, null); |
|
46 | - } |
|
47 | - /**资源ID(resourceId)的生成*/ |
|
48 | - public function buildResourceId() |
|
49 | - { |
|
50 | - $jsonData = array(); |
|
51 | - if (!empty($this->namespace)) { |
|
52 | - array_push($jsonData, urldecode($this->namespace)); |
|
53 | - } |
|
54 | - if (!empty($this->dir)) { |
|
55 | - array_push($jsonData, urldecode($this->dir)); |
|
56 | - } |
|
57 | - if (!empty($this->name)) { |
|
58 | - array_push($jsonData, urldecode($this->name)); |
|
59 | - } |
|
60 | - return EncodeUtils::encodeWithURLSafeBase64(json_encode($jsonData, true)); |
|
61 | - } |
|
62 | - /**对URL中文进行编码*/ |
|
63 | - protected function urlencodeCh($str) |
|
64 | - { |
|
65 | - return preg_replace_callback('/[^\0-\127]+/', function ($match) { |
|
66 | - return urlencode($match[0]); |
|
67 | - }, $str); |
|
68 | - } |
|
69 | - public function toString() |
|
70 | - { |
|
71 | - return "namespace={$this->namespace}, dir={$this->dir}, name={$this->name}"; |
|
72 | - } |
|
73 | - public function toArray() |
|
74 | - { |
|
75 | - return array("namespace" => $this->namespace, "dir" => $this->dir, "name" => $this->name); |
|
76 | - } |
|
77 | - /*###################下面是属性的get和set方法###############*/ |
|
78 | - /**设置路径*/ |
|
79 | - public function setNamespace($namespace) |
|
80 | - { |
|
81 | - $this->namespace = $namespace; |
|
82 | - return $this; |
|
83 | - } |
|
84 | - /**设置路径*/ |
|
85 | - public function setDir($dir) |
|
86 | - { |
|
87 | - $this->dir = $dir; |
|
88 | - return $this; |
|
89 | - } |
|
90 | - /**设置文件名*/ |
|
91 | - public function setName($filename) |
|
92 | - { |
|
93 | - $this->name = $filename; |
|
94 | - return $this; |
|
95 | - } |
|
33 | + public function checkFileInfo($dirState = false, $nameState = false) |
|
34 | + { |
|
35 | + if ($nameState && empty($this->name)) { |
|
36 | + return array(false, "file's name is empty.[{$this->toString()}]"); // 1:若需要进行文件名name检测,则判断文件名是否为空 |
|
37 | + } |
|
38 | + if ($dirState) { |
|
39 | + if (empty($this->dir)) { |
|
40 | + $this->dir = '/'; // 2:判断路径是否为空,若为空,则默认为根目录'/' |
|
41 | + } elseif (strpos($this->dir, '/') !== 0) { |
|
42 | + $this->dir = '/' . $this->dir; // 3:判断路径是否以'/'开头,若不是,则添加'/' |
|
43 | + } |
|
44 | + } |
|
45 | + return array(true, null); |
|
46 | + } |
|
47 | + /**资源ID(resourceId)的生成*/ |
|
48 | + public function buildResourceId() |
|
49 | + { |
|
50 | + $jsonData = array(); |
|
51 | + if (!empty($this->namespace)) { |
|
52 | + array_push($jsonData, urldecode($this->namespace)); |
|
53 | + } |
|
54 | + if (!empty($this->dir)) { |
|
55 | + array_push($jsonData, urldecode($this->dir)); |
|
56 | + } |
|
57 | + if (!empty($this->name)) { |
|
58 | + array_push($jsonData, urldecode($this->name)); |
|
59 | + } |
|
60 | + return EncodeUtils::encodeWithURLSafeBase64(json_encode($jsonData, true)); |
|
61 | + } |
|
62 | + /**对URL中文进行编码*/ |
|
63 | + protected function urlencodeCh($str) |
|
64 | + { |
|
65 | + return preg_replace_callback('/[^\0-\127]+/', function ($match) { |
|
66 | + return urlencode($match[0]); |
|
67 | + }, $str); |
|
68 | + } |
|
69 | + public function toString() |
|
70 | + { |
|
71 | + return "namespace={$this->namespace}, dir={$this->dir}, name={$this->name}"; |
|
72 | + } |
|
73 | + public function toArray() |
|
74 | + { |
|
75 | + return array("namespace" => $this->namespace, "dir" => $this->dir, "name" => $this->name); |
|
76 | + } |
|
77 | + /*###################下面是属性的get和set方法###############*/ |
|
78 | + /**设置路径*/ |
|
79 | + public function setNamespace($namespace) |
|
80 | + { |
|
81 | + $this->namespace = $namespace; |
|
82 | + return $this; |
|
83 | + } |
|
84 | + /**设置路径*/ |
|
85 | + public function setDir($dir) |
|
86 | + { |
|
87 | + $this->dir = $dir; |
|
88 | + return $this; |
|
89 | + } |
|
90 | + /**设置文件名*/ |
|
91 | + public function setName($filename) |
|
92 | + { |
|
93 | + $this->name = $filename; |
|
94 | + return $this; |
|
95 | + } |
|
96 | 96 | } |
@@ -5,45 +5,45 @@ |
||
5 | 5 | /**视频截图的参数*/ |
6 | 6 | class SnapShotOption extends MediaResOption |
7 | 7 | { |
8 | - /** 视频截图的位置,单位为毫秒。该属性必须*/ |
|
9 | - private $time; |
|
10 | - /** 通知url,任务结束之后会调用这个url。该属性可选 */ |
|
11 | - private $notifyUrl; |
|
12 | - /**检测视频截图参数是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/ |
|
13 | - public function checkOptionParameters() |
|
14 | - { |
|
15 | - list($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法 |
|
16 | - if (!$valid) { |
|
17 | - return array($valid, $msg, null); |
|
18 | - } |
|
19 | - if (empty($this->time) || !is_int($this->time) || $this->time < 0) { |
|
20 | - return array(false, "time is empty or invalid.", null); // 是否设置时间,且时间是否合法 |
|
21 | - } |
|
22 | - return $this->getOptionsHttpBody(); //返回http请求体 |
|
23 | - } |
|
8 | + /** 视频截图的位置,单位为毫秒。该属性必须*/ |
|
9 | + private $time; |
|
10 | + /** 通知url,任务结束之后会调用这个url。该属性可选 */ |
|
11 | + private $notifyUrl; |
|
12 | + /**检测视频截图参数是否合法。如果合法,则返回http请求体<p> 返回格式{$isValid, $message, $httpBody}*/ |
|
13 | + public function checkOptionParameters() |
|
14 | + { |
|
15 | + list($valid, $msg) = parent::checkOptionParameters(); //检测输入输出资源是否合法 |
|
16 | + if (!$valid) { |
|
17 | + return array($valid, $msg, null); |
|
18 | + } |
|
19 | + if (empty($this->time) || !is_int($this->time) || $this->time < 0) { |
|
20 | + return array(false, "time is empty or invalid.", null); // 是否设置时间,且时间是否合法 |
|
21 | + } |
|
22 | + return $this->getOptionsHttpBody(); //返回http请求体 |
|
23 | + } |
|
24 | 24 | |
25 | - /**构建多媒体转码所需的http请求体*/ |
|
26 | - public function getOptionsHttpBody() |
|
27 | - { |
|
28 | - //必须的参数 |
|
29 | - $httpBody = 'input=' . $this->getInputResId(); |
|
30 | - $httpBody .= '&output=' . $this->getOutputResId(); |
|
31 | - $httpBody .= '&time=' . $this->time; |
|
32 | - // 可选的参数 |
|
33 | - if (isset($this->notifyUrl)) { |
|
34 | - $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
35 | - } |
|
36 | - return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体 |
|
37 | - } |
|
25 | + /**构建多媒体转码所需的http请求体*/ |
|
26 | + public function getOptionsHttpBody() |
|
27 | + { |
|
28 | + //必须的参数 |
|
29 | + $httpBody = 'input=' . $this->getInputResId(); |
|
30 | + $httpBody .= '&output=' . $this->getOutputResId(); |
|
31 | + $httpBody .= '&time=' . $this->time; |
|
32 | + // 可选的参数 |
|
33 | + if (isset($this->notifyUrl)) { |
|
34 | + $httpBody .= '¬ifyUrl=' . urlencode($this->notifyUrl); |
|
35 | + } |
|
36 | + return array(true, "valid", $httpBody); //视频转码参数合法,返回http请求体 |
|
37 | + } |
|
38 | 38 | |
39 | - /**设置视频截图的位置,单位为毫秒。改参数必须设置*/ |
|
40 | - public function setTime($time) |
|
41 | - { |
|
42 | - $this->time = $time; |
|
43 | - } |
|
44 | - /**设置截图完成后的通知url。可选*/ |
|
45 | - public function setNotifyUrl($notifyUrl) |
|
46 | - { |
|
47 | - $this->notifyUrl = $notifyUrl; |
|
48 | - } |
|
39 | + /**设置视频截图的位置,单位为毫秒。改参数必须设置*/ |
|
40 | + public function setTime($time) |
|
41 | + { |
|
42 | + $this->time = $time; |
|
43 | + } |
|
44 | + /**设置截图完成后的通知url。可选*/ |
|
45 | + public function setNotifyUrl($notifyUrl) |
|
46 | + { |
|
47 | + $this->notifyUrl = $notifyUrl; |
|
48 | + } |
|
49 | 49 | } |