| Conditions | 2 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function sync(Target $target, Result $result) |
||
| 30 | { |
||
| 31 | $sourcePath = $target->getPathname(); |
||
| 32 | $targetPath = $this->path . '/' . $target->getFilename(); |
||
| 33 | |||
| 34 | $s3 = S3Client::factory( |
||
|
|
|||
| 35 | [ |
||
| 36 | 'signature' => 'v4', |
||
| 37 | 'region' => $this->region, |
||
| 38 | 'credentials' => [ |
||
| 39 | 'key' => $this->key, |
||
| 40 | 'secret' => $this->secret, |
||
| 41 | ] |
||
| 42 | ] |
||
| 43 | ); |
||
| 44 | |||
| 45 | try { |
||
| 46 | $fh = fopen($sourcePath, 'r'); |
||
| 47 | $s3->upload($this->bucket, $targetPath, $fh, $this->acl); |
||
| 48 | } catch (\Exception $e) { |
||
| 49 | throw new Exception($e->getMessage(), null, $e); |
||
| 50 | } |
||
| 51 | |||
| 52 | $result->debug('upload: done'); |
||
| 53 | } |
||
| 55 |