作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -32,18 +32,16 @@ class CopyImageFileListener implements ShouldQueue @@ -32,18 +32,16 @@ class CopyImageFileListener implements ShouldQueue
32 if(!empty($imageList)){ 32 if(!empty($imageList)){
33 $amazonS3Service = new AmazonS3Service(); 33 $amazonS3Service = new AmazonS3Service();
34 foreach ($imageList as $k => $v){ 34 foreach ($imageList as $k => $v){
35 - $rs = $amazonS3Service->syncImageFiles(getImageUrl($v['path']),$v['size']); 35 + $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
36 $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]); 36 $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
37 } 37 }
38 } 38 }
39 -  
40 - sleep(2);  
41 $fileModel = new FileModel(); 39 $fileModel = new FileModel();
42 $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos']); 40 $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos']);
43 if(!empty($fileList)){ 41 if(!empty($fileList)){
44 $amazonS3Service = new AmazonS3Service(); 42 $amazonS3Service = new AmazonS3Service();
45 foreach ($fileList as $k => $v){ 43 foreach ($fileList as $k => $v){
46 - $amazonS3Service->syncImageFiles(getImageUrl($v['path']),$v['size']); 44 + $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
47 $fileList->edit(['is_cos'=>0],['id'=>$v['id']]); 45 $fileList->edit(['is_cos'=>0],['id'=>$v['id']]);
48 } 46 }
49 } 47 }
@@ -69,7 +69,7 @@ class AmazonS3Service @@ -69,7 +69,7 @@ class AmazonS3Service
69 $file_link = $this->fetchRemoteImage($files); 69 $file_link = $this->fetchRemoteImage($files);
70 @file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$file_link, true) . PHP_EOL, FILE_APPEND); 70 @file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$file_link, true) . PHP_EOL, FILE_APPEND);
71 $key = str_replace_url($files); 71 $key = str_replace_url($files);
72 -// try { 72 + try {
73 $context = stream_context_create([ 73 $context = stream_context_create([
74 'ssl' => [ 74 'ssl' => [
75 'verify_peer' => false, 75 'verify_peer' => false,
@@ -79,13 +79,13 @@ class AmazonS3Service @@ -79,13 +79,13 @@ class AmazonS3Service
79 $file_content = file_get_contents($file_link, false, $context); 79 $file_content = file_get_contents($file_link, false, $context);
80 $result = $this->s3->putObject([ 80 $result = $this->s3->putObject([
81 'Bucket' => $this->bucket, 81 'Bucket' => $this->bucket,
82 - 'Key' => $key, 82 + 'Key' => ltrim($key,'/'),
83 'Body' => $file_content, 83 'Body' => $file_content,
84 ]); 84 ]);
85 return $result['ObjectURL']; 85 return $result['ObjectURL'];
86 -// } catch (AwsException $e) {  
87 -// return '上传文件到S3时发生错误:' . $e->getMessage();  
88 -// } 86 + } catch (AwsException $e) {
  87 + return '上传文件到S3时发生错误:' . $e->getMessage();
  88 + }
89 } 89 }
90 90
91 /** 91 /**