作者 lyh

gx

... ... @@ -32,7 +32,7 @@ class CopyImageFileListener implements ShouldQueue
if(!empty($imageList)){
$amazonS3Service = new AmazonS3Service();
foreach ($imageList as $k => $v){
$rs = $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
$rs = $amazonS3Service->syncImageFiles(getImageUrl($v['path']),$v['size']);
$imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$rs, true) . PHP_EOL, FILE_APPEND);
}
... ... @@ -44,7 +44,7 @@ class CopyImageFileListener implements ShouldQueue
if(!empty($fileList)){
$amazonS3Service = new AmazonS3Service();
foreach ($fileList as $k => $v){
$amazonS3Service->syncImageFiles(getImageUrl($v['path']));
$amazonS3Service->syncImageFiles(getImageUrl($v['path']),$v['size']);
$fileList->edit(['is_cos'=>0],['id'=>$v['id']]);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('文件:'.$v['id'], true) . PHP_EOL, FILE_APPEND);
}
... ...
... ... @@ -64,7 +64,7 @@ class AmazonS3Service
* @method :post
* @time :2024/1/23 9:20
*/
public function syncImageFiles($files)
public function syncImageFiles($files,$size)
{
$key = str_replace_url($files);
// try {
... ... @@ -83,12 +83,11 @@ class AmazonS3Service
if ($file_handle === false) {
return '无法打开文件';
}
$content_length = filesize($files);
$result = $this->s3->putObject([
'Bucket' => $this->bucket,
'Key' => $key,
'Body' => $file_handle,
'ContentLength' => $content_length
'ContentLength' => $size
]);
return $result['ObjectURL'];
// } catch (AwsException $e) {
... ...