Passed
Branch master (edefdc)
by xiaohui
04:15
created
src/Plugins/UploadToken.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Plugins/GetUrl.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/WantuFileAdapter.php 2 patches
Indentation   +467 added lines, -467 removed lines patch added patch discarded remove patch
@@ -12,471 +12,471 @@
 block discarded – undo
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
-     * QiniuAdapter constructor.
34
-     *
35
-     * @param string $accessKey
36
-     * @param string $secretKey
37
-     * @param string $namespace
38
-     */
39
-    public function __construct($accessKey, $secretKey, $namespace, $origin)
40
-    {
41
-        $client = new Client($accessKey, $secretKey, $namespace);
42
-        $this->setClient($client, $namespace, $origin);
43
-    }
44
-
45
-    public function setClient(Client $client, $namespace, $origin)
46
-    {
47
-        $this->client = $client;
48
-        $this->namespace = $namespace;
49
-        $this->domain = $origin;
50
-    }
51
-
52
-    /**
53
-     * Write a new file.
54
-     *
55
-     * @param string $path
56
-     * @param string $contents
57
-     * @param Config $config   Config object
58
-     *
59
-     * @return array|false false on failure file meta data on success
60
-     */
61
-    public function write($path, $contents, Config $config)
62
-    {
63
-        $uploadPolicy = new UploadPolicy([
64
-            'namespace' => $this->namespace,
65
-            'dir' => preg_replace('/^\./', '', dirname($path)),
66
-            'name' => last(explode("/", $path)),
67
-        ]);
68
-
69
-        return $this->client->uploadData($contents, $uploadPolicy);
70
-    }
71
-
72
-    /**
73
-     * Write a new file using a stream.
74
-     *
75
-     * @param string   $path
76
-     * @param resource $resource
77
-     * @param Config   $config   Config object
78
-     *
79
-     * @return array|false false on failure file meta data on success
80
-     */
81
-    public function writeStream($path, $resource, Config $config)
82
-    {
83
-        $contents = '';
84
-
85
-        while (!feof($resource)) {
86
-            $contents .= fread($resource, 1024);
87
-        }
88
-
89
-        $response = $this->write($path, $contents, $config);
90
-
91
-        if (false === $response) {
92
-            return $response;
93
-        }
94
-
95
-        return compact('path');
96
-    }
97
-
98
-    /**
99
-     * Update a file.
100
-     *
101
-     * @param string $path
102
-     * @param string $contents
103
-     * @param Config $config   Config object
104
-     *
105
-     * @return array|false false on failure file meta data on success
106
-     */
107
-    public function update($path, $contents, Config $config)
108
-    {
109
-        $this->delete($path);
110
-
111
-        return $this->write($path, $contents, $config);
112
-    }
113
-
114
-    /**
115
-     * Update a file using a stream.
116
-     *
117
-     * @param string   $path
118
-     * @param resource $resource
119
-     * @param Config   $config   Config object
120
-     *
121
-     * @return array|false false on failure file meta data on success
122
-     */
123
-    public function updateStream($path, $resource, Config $config)
124
-    {
125
-        $this->delete($path);
126
-
127
-        return $this->writeStream($path, $resource, $config);
128
-    }
129
-
130
-    public function put($path, $contents, Config $config)
131
-    {
132
-        return $this->write($path, $contents, $config);
133
-    }
134
-
135
-    public function putStream($path, $resource, Config $config)
136
-    {
137
-        return $this->write($path, $resource, $config);
138
-    }
139
-
140
-    /**
141
-     * Rename a file.
142
-     *
143
-     * @param string $path
144
-     * @param string $newpath
145
-     *
146
-     * @return bool
147
-     */
148
-    public function rename($path, $newpath)
149
-    {
150
-        return $this->client->renameFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)), preg_replace('/^\./', '', dirname($newpath)), last(explode("/", $newpath)));
151
-    }
152
-
153
-    /**
154
-     * Copy a file.
155
-     *
156
-     * @param string $path
157
-     * @param string $newpath
158
-     *
159
-     * @return bool
160
-     */
161
-    public function copy($path, $newpath)
162
-    {
163
-    }
164
-
165
-    /**
166
-     * Delete a file.
167
-     *
168
-     * @param string $path
169
-     *
170
-     * @return bool
171
-     */
172
-    public function delete($path)
173
-    {
174
-        return $this->client->deleteFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)));
175
-    }
176
-
177
-    /**
178
-     * Delete a directory.
179
-     *
180
-     * @param string $dirname
181
-     *
182
-     * @return bool
183
-     */
184
-    public function deleteDir($dirname)
185
-    {
186
-        return $this->client->deleteDir($this->namespace, $dirname);
187
-    }
188
-
189
-    /**
190
-     * Create a directory.
191
-     *
192
-     * @param string $dirname directory name
193
-     * @param Config $config
194
-     *
195
-     * @return array|false
196
-     */
197
-    public function createDir($dirname, Config $config)
198
-    {
199
-        return $this->client->createDir($this->namespace, $dirname);
200
-    }
201
-
202
-    /**
203
-     * Check whether a file exists.
204
-     *
205
-     * @param string $path
206
-     *
207
-     * @return array|bool|null
208
-     */
209
-    public function has($path)
210
-    {
211
-        if (Str::endsWith($path, "/")) {
212
-            return $this->client->existsFolder($this->namespace,  preg_replace('/^\./' , '', dirname( $path)));
213
-        } else {
214
-            return $this->client->existsFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)));
215
-        }
216
-    }
217
-
218
-
219
-    /**
220
-     * Read a file.
221
-     *
222
-     * @param string $path
223
-     *
224
-     * @return array|false
225
-     */
226
-    public function read($path)
227
-    {
228
-        $contents = file_get_contents($this->getUrl($path));
229
-        return compact('contents', 'path');
230
-    }
231
-
232
-    /**
233
-     * Read a file as a stream.
234
-     *
235
-     * @param string $path
236
-     *
237
-     * @return array|false
238
-     */
239
-    public function readStream($path)
240
-    {
241
-    }
242
-
243
-    /**
244
-     * List contents of a directory.
245
-     *
246
-     * @param string $directory
247
-     * @param bool   $recursive
248
-     *
249
-     * @return array
250
-     */
251
-    public function listContents($directory = '', $recursive = false)
252
-    {
253
-        return $this->client->listFiles($this->namespace, $directory, 1, 1000);
254
-    }
255
-
256
-    /**
257
-     * Get all the meta data of a file or directory.
258
-     *
259
-     * @param string $path
260
-     *
261
-     * @return array|false
262
-     */
263
-    public function getMetadata($path)
264
-    {
265
-        return $this->client->getFileInfo($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)));
266
-    }
267
-
268
-    /**
269
-     * Get the size of a file.
270
-     *
271
-     * @param string $path
272
-     *
273
-     * @return array|false
274
-     */
275
-    public function getSize($path)
276
-    {
277
-    }
278
-
279
-
280
-    /**
281
-     * Fetch url to bucket.
282
-     *
283
-     * @param string $path
284
-     * @param string $url
285
-     *
286
-     * @return array|false
287
-     */
288
-    public function fetch($path, $url)
289
-    {
290
-    }
291
-
292
-    /**
293
-     * Get private file download url.
294
-     *
295
-     * @param string $path
296
-     * @param int    $expires
297
-     *
298
-     * @return string
299
-     */
300
-    public function privateDownloadUrl($path, $expires = 3600)
301
-    {
302
-    }
303
-
304
-    /**
305
-     * Refresh file cache.
306
-     *
307
-     * @param string|array $path
308
-     *
309
-     * @return array
310
-     */
311
-    public function refresh($path)
312
-    {
313
-    }
314
-
315
-
316
-    /**
317
-     * Get the mime-type of a file.
318
-     *
319
-     * @param string $path
320
-     *
321
-     * @return array|false
322
-     */
323
-    public function getMimeType($path)
324
-    {
325
-    }
326
-
327
-
328
-    /**
329
-     * Get the timestamp of a file.
330
-     *
331
-     * @param string $path
332
-     *
333
-     * @return array|false
334
-     */
335
-    public function getTimestamp($path)
336
-    {
337
-    }
338
-
339
-
340
-    /**
341
-     * @param \Qiniu\Storage\BucketManager $manager
342
-     *
343
-     * @return $this
344
-     */
345
-    public function setBucketManager(BucketManager $manager)
346
-    {
347
-    }
348
-
349
-
350
-    /**
351
-     * @param \Qiniu\Storage\UploadManager $manager
352
-     *
353
-     * @return $this
354
-     */
355
-    public function setUploadManager(UploadManager $manager)
356
-    {
357
-    }
358
-
359
-
360
-    /**
361
-     * @param \Qiniu\Auth $manager
362
-     *
363
-     * @return $this
364
-     */
365
-    public function setAuthManager(Auth $manager)
366
-    {
367
-    }
368
-
369
-    /**
370
-     * @param CdnManager $manager
371
-     *
372
-     * @return $this
373
-     */
374
-    public function setCdnManager(CdnManager $manager)
375
-    {
376
-    }
377
-
378
-
379
-    /**
380
-     * @return \Qiniu\Storage\BucketManager
381
-     */
382
-    public function getBucketManager()
383
-    {
384
-        return $this->bucketManager ?: $this->bucketManager = new BucketManager($this->getAuthManager());
385
-    }
386
-
387
-    /**
388
-     * @return \Qiniu\Auth
389
-     */
390
-    public function getAuthManager()
391
-    {
392
-        return $this->authManager ?: $this->authManager = new Auth($this->accessKey, $this->secretKey);
393
-    }
394
-
395
-    /**
396
-     * @return \Qiniu\Storage\UploadManager
397
-     */
398
-    public function getUploadManager()
399
-    {
400
-        return $this->uploadManager ?: $this->uploadManager = new UploadManager();
401
-    }
402
-
403
-    /**
404
-     * @return \Qiniu\Cdn\CdnManager
405
-     */
406
-    public function getCdnManager()
407
-    {
408
-        return $this->cdnManager ?: $this->cdnManager = new CdnManager($this->getAuthManager());
409
-    }
410
-
411
-    /**
412
-     * @return string
413
-     */
414
-    public function getBucket()
415
-    {
416
-        return $this->bucket;
417
-    }
418
-
419
-    /**
420
-     * Get the upload token.
421
-     *
422
-     * @param string|null $key
423
-     * @param int         $ttl
424
-     * @param string|null $policy
425
-     * @param string|null $strictPolice
426
-     *
427
-     * @return string
428
-     */
429
-    public function getUploadToken($option = null)
430
-    {
431
-        if ($option === null) {
432
-            $option = ['name' => null, 'ttl' => 3600, ];
433
-        } else if (!isset($option['ttl']) || !$option['ttl']) {
434
-            $option['ttl'] = 3600;
435
-        }
436
-
437
-        return $this->client->getUploadToken(collect([
438
-            'expiration' => Carbon::now()->addSeconds($option['ttl'])->timestamp * 1000,
439
-            'insertOnly' => Conf::INSERT_ONLY_TRUE
440
-        ])->merge(collect($option)->except(['ttl',])));
441
-    }
442
-
443
-    /**
444
-     * @param array $stats
445
-     *
446
-     * @return array
447
-     */
448
-    protected function normalizeFileInfo(array $stats)
449
-    {
450
-        return [
451
-            'type' => 'file',
452
-            'path' => $stats['key'],
453
-            'timestamp' => floor($stats['putTime'] / 10000000),
454
-            'size' => $stats['fsize'],
455
-        ];
456
-    }
457
-
458
-    /**
459
-     * Get resource url.
460
-     *
461
-     * @param string $path
462
-     *
463
-     * @return string
464
-     */
465
-    public function getUrl($path)
466
-    {
467
-        return $this->normalizeHost($this->domain) . ltrim($path, '/');
468
-    }
469
-
470
-    /**
471
-     * @param string $domain
472
-     *
473
-     * @return string
474
-     */
475
-    protected function normalizeHost($domain)
476
-    {
477
-        if (0 !== stripos($domain, 'https://') && 0 !== stripos($domain, 'http://')) {
478
-            $domain = "http://{$domain}";
479
-        }
480
-        return rtrim($domain, '/') . '/';
481
-    }
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
+	 * QiniuAdapter constructor.
34
+	 *
35
+	 * @param string $accessKey
36
+	 * @param string $secretKey
37
+	 * @param string $namespace
38
+	 */
39
+	public function __construct($accessKey, $secretKey, $namespace, $origin)
40
+	{
41
+		$client = new Client($accessKey, $secretKey, $namespace);
42
+		$this->setClient($client, $namespace, $origin);
43
+	}
44
+
45
+	public function setClient(Client $client, $namespace, $origin)
46
+	{
47
+		$this->client = $client;
48
+		$this->namespace = $namespace;
49
+		$this->domain = $origin;
50
+	}
51
+
52
+	/**
53
+	 * Write a new file.
54
+	 *
55
+	 * @param string $path
56
+	 * @param string $contents
57
+	 * @param Config $config   Config object
58
+	 *
59
+	 * @return array|false false on failure file meta data on success
60
+	 */
61
+	public function write($path, $contents, Config $config)
62
+	{
63
+		$uploadPolicy = new UploadPolicy([
64
+			'namespace' => $this->namespace,
65
+			'dir' => preg_replace('/^\./', '', dirname($path)),
66
+			'name' => last(explode("/", $path)),
67
+		]);
68
+
69
+		return $this->client->uploadData($contents, $uploadPolicy);
70
+	}
71
+
72
+	/**
73
+	 * Write a new file using a stream.
74
+	 *
75
+	 * @param string   $path
76
+	 * @param resource $resource
77
+	 * @param Config   $config   Config object
78
+	 *
79
+	 * @return array|false false on failure file meta data on success
80
+	 */
81
+	public function writeStream($path, $resource, Config $config)
82
+	{
83
+		$contents = '';
84
+
85
+		while (!feof($resource)) {
86
+			$contents .= fread($resource, 1024);
87
+		}
88
+
89
+		$response = $this->write($path, $contents, $config);
90
+
91
+		if (false === $response) {
92
+			return $response;
93
+		}
94
+
95
+		return compact('path');
96
+	}
97
+
98
+	/**
99
+	 * Update a file.
100
+	 *
101
+	 * @param string $path
102
+	 * @param string $contents
103
+	 * @param Config $config   Config object
104
+	 *
105
+	 * @return array|false false on failure file meta data on success
106
+	 */
107
+	public function update($path, $contents, Config $config)
108
+	{
109
+		$this->delete($path);
110
+
111
+		return $this->write($path, $contents, $config);
112
+	}
113
+
114
+	/**
115
+	 * Update a file using a stream.
116
+	 *
117
+	 * @param string   $path
118
+	 * @param resource $resource
119
+	 * @param Config   $config   Config object
120
+	 *
121
+	 * @return array|false false on failure file meta data on success
122
+	 */
123
+	public function updateStream($path, $resource, Config $config)
124
+	{
125
+		$this->delete($path);
126
+
127
+		return $this->writeStream($path, $resource, $config);
128
+	}
129
+
130
+	public function put($path, $contents, Config $config)
131
+	{
132
+		return $this->write($path, $contents, $config);
133
+	}
134
+
135
+	public function putStream($path, $resource, Config $config)
136
+	{
137
+		return $this->write($path, $resource, $config);
138
+	}
139
+
140
+	/**
141
+	 * Rename a file.
142
+	 *
143
+	 * @param string $path
144
+	 * @param string $newpath
145
+	 *
146
+	 * @return bool
147
+	 */
148
+	public function rename($path, $newpath)
149
+	{
150
+		return $this->client->renameFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)), preg_replace('/^\./', '', dirname($newpath)), last(explode("/", $newpath)));
151
+	}
152
+
153
+	/**
154
+	 * Copy a file.
155
+	 *
156
+	 * @param string $path
157
+	 * @param string $newpath
158
+	 *
159
+	 * @return bool
160
+	 */
161
+	public function copy($path, $newpath)
162
+	{
163
+	}
164
+
165
+	/**
166
+	 * Delete a file.
167
+	 *
168
+	 * @param string $path
169
+	 *
170
+	 * @return bool
171
+	 */
172
+	public function delete($path)
173
+	{
174
+		return $this->client->deleteFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)));
175
+	}
176
+
177
+	/**
178
+	 * Delete a directory.
179
+	 *
180
+	 * @param string $dirname
181
+	 *
182
+	 * @return bool
183
+	 */
184
+	public function deleteDir($dirname)
185
+	{
186
+		return $this->client->deleteDir($this->namespace, $dirname);
187
+	}
188
+
189
+	/**
190
+	 * Create a directory.
191
+	 *
192
+	 * @param string $dirname directory name
193
+	 * @param Config $config
194
+	 *
195
+	 * @return array|false
196
+	 */
197
+	public function createDir($dirname, Config $config)
198
+	{
199
+		return $this->client->createDir($this->namespace, $dirname);
200
+	}
201
+
202
+	/**
203
+	 * Check whether a file exists.
204
+	 *
205
+	 * @param string $path
206
+	 *
207
+	 * @return array|bool|null
208
+	 */
209
+	public function has($path)
210
+	{
211
+		if (Str::endsWith($path, "/")) {
212
+			return $this->client->existsFolder($this->namespace,  preg_replace('/^\./' , '', dirname( $path)));
213
+		} else {
214
+			return $this->client->existsFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)));
215
+		}
216
+	}
217
+
218
+
219
+	/**
220
+	 * Read a file.
221
+	 *
222
+	 * @param string $path
223
+	 *
224
+	 * @return array|false
225
+	 */
226
+	public function read($path)
227
+	{
228
+		$contents = file_get_contents($this->getUrl($path));
229
+		return compact('contents', 'path');
230
+	}
231
+
232
+	/**
233
+	 * Read a file as a stream.
234
+	 *
235
+	 * @param string $path
236
+	 *
237
+	 * @return array|false
238
+	 */
239
+	public function readStream($path)
240
+	{
241
+	}
242
+
243
+	/**
244
+	 * List contents of a directory.
245
+	 *
246
+	 * @param string $directory
247
+	 * @param bool   $recursive
248
+	 *
249
+	 * @return array
250
+	 */
251
+	public function listContents($directory = '', $recursive = false)
252
+	{
253
+		return $this->client->listFiles($this->namespace, $directory, 1, 1000);
254
+	}
255
+
256
+	/**
257
+	 * Get all the meta data of a file or directory.
258
+	 *
259
+	 * @param string $path
260
+	 *
261
+	 * @return array|false
262
+	 */
263
+	public function getMetadata($path)
264
+	{
265
+		return $this->client->getFileInfo($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)));
266
+	}
267
+
268
+	/**
269
+	 * Get the size of a file.
270
+	 *
271
+	 * @param string $path
272
+	 *
273
+	 * @return array|false
274
+	 */
275
+	public function getSize($path)
276
+	{
277
+	}
278
+
279
+
280
+	/**
281
+	 * Fetch url to bucket.
282
+	 *
283
+	 * @param string $path
284
+	 * @param string $url
285
+	 *
286
+	 * @return array|false
287
+	 */
288
+	public function fetch($path, $url)
289
+	{
290
+	}
291
+
292
+	/**
293
+	 * Get private file download url.
294
+	 *
295
+	 * @param string $path
296
+	 * @param int    $expires
297
+	 *
298
+	 * @return string
299
+	 */
300
+	public function privateDownloadUrl($path, $expires = 3600)
301
+	{
302
+	}
303
+
304
+	/**
305
+	 * Refresh file cache.
306
+	 *
307
+	 * @param string|array $path
308
+	 *
309
+	 * @return array
310
+	 */
311
+	public function refresh($path)
312
+	{
313
+	}
314
+
315
+
316
+	/**
317
+	 * Get the mime-type of a file.
318
+	 *
319
+	 * @param string $path
320
+	 *
321
+	 * @return array|false
322
+	 */
323
+	public function getMimeType($path)
324
+	{
325
+	}
326
+
327
+
328
+	/**
329
+	 * Get the timestamp of a file.
330
+	 *
331
+	 * @param string $path
332
+	 *
333
+	 * @return array|false
334
+	 */
335
+	public function getTimestamp($path)
336
+	{
337
+	}
338
+
339
+
340
+	/**
341
+	 * @param \Qiniu\Storage\BucketManager $manager
342
+	 *
343
+	 * @return $this
344
+	 */
345
+	public function setBucketManager(BucketManager $manager)
346
+	{
347
+	}
348
+
349
+
350
+	/**
351
+	 * @param \Qiniu\Storage\UploadManager $manager
352
+	 *
353
+	 * @return $this
354
+	 */
355
+	public function setUploadManager(UploadManager $manager)
356
+	{
357
+	}
358
+
359
+
360
+	/**
361
+	 * @param \Qiniu\Auth $manager
362
+	 *
363
+	 * @return $this
364
+	 */
365
+	public function setAuthManager(Auth $manager)
366
+	{
367
+	}
368
+
369
+	/**
370
+	 * @param CdnManager $manager
371
+	 *
372
+	 * @return $this
373
+	 */
374
+	public function setCdnManager(CdnManager $manager)
375
+	{
376
+	}
377
+
378
+
379
+	/**
380
+	 * @return \Qiniu\Storage\BucketManager
381
+	 */
382
+	public function getBucketManager()
383
+	{
384
+		return $this->bucketManager ?: $this->bucketManager = new BucketManager($this->getAuthManager());
385
+	}
386
+
387
+	/**
388
+	 * @return \Qiniu\Auth
389
+	 */
390
+	public function getAuthManager()
391
+	{
392
+		return $this->authManager ?: $this->authManager = new Auth($this->accessKey, $this->secretKey);
393
+	}
394
+
395
+	/**
396
+	 * @return \Qiniu\Storage\UploadManager
397
+	 */
398
+	public function getUploadManager()
399
+	{
400
+		return $this->uploadManager ?: $this->uploadManager = new UploadManager();
401
+	}
402
+
403
+	/**
404
+	 * @return \Qiniu\Cdn\CdnManager
405
+	 */
406
+	public function getCdnManager()
407
+	{
408
+		return $this->cdnManager ?: $this->cdnManager = new CdnManager($this->getAuthManager());
409
+	}
410
+
411
+	/**
412
+	 * @return string
413
+	 */
414
+	public function getBucket()
415
+	{
416
+		return $this->bucket;
417
+	}
418
+
419
+	/**
420
+	 * Get the upload token.
421
+	 *
422
+	 * @param string|null $key
423
+	 * @param int         $ttl
424
+	 * @param string|null $policy
425
+	 * @param string|null $strictPolice
426
+	 *
427
+	 * @return string
428
+	 */
429
+	public function getUploadToken($option = null)
430
+	{
431
+		if ($option === null) {
432
+			$option = ['name' => null, 'ttl' => 3600, ];
433
+		} else if (!isset($option['ttl']) || !$option['ttl']) {
434
+			$option['ttl'] = 3600;
435
+		}
436
+
437
+		return $this->client->getUploadToken(collect([
438
+			'expiration' => Carbon::now()->addSeconds($option['ttl'])->timestamp * 1000,
439
+			'insertOnly' => Conf::INSERT_ONLY_TRUE
440
+		])->merge(collect($option)->except(['ttl',])));
441
+	}
442
+
443
+	/**
444
+	 * @param array $stats
445
+	 *
446
+	 * @return array
447
+	 */
448
+	protected function normalizeFileInfo(array $stats)
449
+	{
450
+		return [
451
+			'type' => 'file',
452
+			'path' => $stats['key'],
453
+			'timestamp' => floor($stats['putTime'] / 10000000),
454
+			'size' => $stats['fsize'],
455
+		];
456
+	}
457
+
458
+	/**
459
+	 * Get resource url.
460
+	 *
461
+	 * @param string $path
462
+	 *
463
+	 * @return string
464
+	 */
465
+	public function getUrl($path)
466
+	{
467
+		return $this->normalizeHost($this->domain) . ltrim($path, '/');
468
+	}
469
+
470
+	/**
471
+	 * @param string $domain
472
+	 *
473
+	 * @return string
474
+	 */
475
+	protected function normalizeHost($domain)
476
+	{
477
+		if (0 !== stripos($domain, 'https://') && 0 !== stripos($domain, 'http://')) {
478
+			$domain = "http://{$domain}";
479
+		}
480
+		return rtrim($domain, '/') . '/';
481
+	}
482 482
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     public function has($path)
210 210
     {
211 211
         if (Str::endsWith($path, "/")) {
212
-            return $this->client->existsFolder($this->namespace,  preg_replace('/^\./' , '', dirname( $path)));
212
+            return $this->client->existsFolder($this->namespace, preg_replace('/^\./', '', dirname($path)));
213 213
         } else {
214 214
             return $this->client->existsFile($this->namespace, preg_replace('/^\./', '', dirname($path)), last(explode("/", $path)));
215 215
         }
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
         return $this->client->getUploadToken(collect([
438 438
             'expiration' => Carbon::now()->addSeconds($option['ttl'])->timestamp * 1000,
439 439
             'insertOnly' => Conf::INSERT_ONLY_TRUE
440
-        ])->merge(collect($option)->except(['ttl',])));
440
+        ])->merge(collect($option)->except(['ttl', ])));
441 441
     }
442 442
 
443 443
     /**
Please login to merge, or discard this patch.