|
...
|
...
|
@@ -64,30 +64,15 @@ class AmazonS3Service |
|
|
|
* @method :post
|
|
|
|
* @time :2024/1/23 9:20
|
|
|
|
*/
|
|
|
|
public function syncImageFiles($files,$size)
|
|
|
|
public function syncImageFiles($files)
|
|
|
|
{
|
|
|
|
$key = str_replace_url($files);
|
|
|
|
// try {
|
|
|
|
$opts = [
|
|
|
|
'http' => [
|
|
|
|
'method' => 'GET',
|
|
|
|
'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
|
|
|
|
],
|
|
|
|
'ssl' => [
|
|
|
|
'verify_peer' => false,
|
|
|
|
'verify_peer_name' => false
|
|
|
|
]
|
|
|
|
];
|
|
|
|
$stream_context = stream_context_create($opts);
|
|
|
|
$file_handle = fopen($files, 'rb', null, $stream_context);
|
|
|
|
if ($file_handle === false) {
|
|
|
|
return '无法打开文件';
|
|
|
|
}
|
|
|
|
$file_content = file_get_contents($files);
|
|
|
|
$result = $this->s3->putObject([
|
|
|
|
'Bucket' => $this->bucket,
|
|
|
|
'Key' => $key,
|
|
|
|
'Body' => $file_handle,
|
|
|
|
'ContentLength' => $size
|
|
|
|
'Body' => $file_content,
|
|
|
|
]);
|
|
|
|
return $result['ObjectURL'];
|
|
|
|
// } catch (AwsException $e) {
|
...
|
...
|
|