|
...
|
...
|
@@ -5,6 +5,9 @@ namespace App\Listeners; |
|
|
|
use App\Events\CopyImageFile;
|
|
|
|
use App\Events\UpdateHtml;
|
|
|
|
use App\Jobs\updateHtmlJob;
|
|
|
|
use App\Models\File\File as FileModel;
|
|
|
|
use App\Models\File\Image as ImageModel;
|
|
|
|
use App\Services\AmazonS3Service;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
|
|
|
|
class CopyImageFileListener implements ShouldQueue
|
|
...
|
...
|
@@ -23,16 +26,28 @@ class CopyImageFileListener implements ShouldQueue |
|
|
|
public function handle(CopyImageFile $event)
|
|
|
|
{
|
|
|
|
$this->param = $event->data;
|
|
|
|
$imageModel = new ImageModel();
|
|
|
|
//获取当前项目的所有图片
|
|
|
|
$imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos']);
|
|
|
|
if(!empty($imageList)){
|
|
|
|
$amazonS3Service = new AmazonS3Service();
|
|
|
|
foreach ($imageList as $k => $v){
|
|
|
|
$amazonS3Service->syncImageFiles(getImageUrl($v['path']));
|
|
|
|
$imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :同步图片文件到亚马逊
|
|
|
|
* @name :uploadImageFile
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/1/26 10:15
|
|
|
|
*/
|
|
|
|
public function uploadImageFile(){
|
|
|
|
|
|
|
|
}
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$v['id'], true) . PHP_EOL, FILE_APPEND);
|
|
|
|
sleep(2);
|
|
|
|
$fileModel = new FileModel();
|
|
|
|
$fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos']);
|
|
|
|
if(!empty($fileList)){
|
|
|
|
$amazonS3Service = new AmazonS3Service();
|
|
|
|
foreach ($fileList as $k => $v){
|
|
|
|
$amazonS3Service->syncImageFiles(getImageUrl($v['path']));
|
|
|
|
$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);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|