1 | <?php |
||
2 | |||
3 | namespace Freyo\Flysystem\QcloudCOSv4\Plugins; |
||
4 | |||
5 | use League\Flysystem\Plugin\AbstractPlugin; |
||
6 | |||
7 | class PutRemoteFileAs extends AbstractPlugin |
||
8 | { |
||
9 | /** |
||
10 | * Get the method name. |
||
11 | * |
||
12 | * @return string |
||
13 | */ |
||
14 | public function getMethod() |
||
15 | { |
||
16 | return 'putRemoteFileAs'; |
||
17 | } |
||
18 | |||
19 | /** |
||
20 | * @param $path |
||
21 | * @param $remoteUrl |
||
22 | * @param $name |
||
23 | * @param array $options |
||
24 | * |
||
25 | * @return bool |
||
26 | */ |
||
27 | public function handle($path, $remoteUrl, $name, array $options = []) |
||
28 | { |
||
29 | //Get file from remote url |
||
30 | $contents = (new \GuzzleHttp\Client(['verify' => false])) |
||
31 | ->request('get', $remoteUrl) |
||
32 | ->getBody() |
||
33 | ->getContents(); |
||
34 | |||
35 | $path = trim($path.'/'.$name, '/'); |
||
36 | |||
37 | return $this->filesystem->put($path, $contents, $options) ? $path : false; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
38 | } |
||
39 | } |
||
40 |