@@ 46-63 (lines=18) @@ | ||
43 | bucket-owner-full-control |
|
44 | @param $params Additional parameters you want to pass to S3 client. |
|
45 | */ |
|
46 | public function saveFile($file_location, $s3_location, $acl = 'private', $params = []) |
|
47 | { |
|
48 | if ($this->s3 == null) |
|
49 | return false; |
|
50 | ||
51 | $this->getClient(); |
|
52 | ||
53 | try { |
|
54 | $result = $this->s3->putObject([ |
|
55 | 'Bucket' => $this->bucket_name, |
|
56 | 'Key' => $s3_location, |
|
57 | 'SourceFile' => $file_location, |
|
58 | 'ACL' => $acl, |
|
59 | ] + $params); |
|
60 | } catch (\Exception $e) { |
|
61 | return false; |
|
62 | } |
|
63 | } |
|
64 | ||
65 | /* |
|
66 | @param $file_content The file content to upload to s3 |
|
@@ 73-90 (lines=18) @@ | ||
70 | bucket-owner-full-control |
|
71 | @param $params Additional parameters you want to pass to S3 client. |
|
72 | */ |
|
73 | public function saveFileContent($file_content, $s3_location, $acl = 'private', $params = []) |
|
74 | { |
|
75 | if ($this->s3 == null) |
|
76 | return false; |
|
77 | ||
78 | $this->getClient(); |
|
79 | ||
80 | try { |
|
81 | $result = $this->s3->putObject([ |
|
82 | 'Bucket' => $this->bucket_name, |
|
83 | 'Key' => $s3_location, |
|
84 | 'Body' => $file_content, |
|
85 | 'ACL' => $acl, |
|
86 | ] + $params); |
|
87 | } catch (\Exception $e) { |
|
88 | return false; |
|
89 | } |
|
90 | } |
|
91 | ||
92 | /* |
|
93 | @param $s3_location the location of the file on s3 |