作者 lyh

变更数据

@@ -232,7 +232,7 @@ class IndexController extends BaseController @@ -232,7 +232,7 @@ class IndexController extends BaseController
232 public function prInfoDownload() 232 public function prInfoDownload()
233 { 233 {
234 $url = 'http://crawl.scraper.waimaoq.com/export/issuewire?token=MT0CM7y4tdFTFTm'; 234 $url = 'http://crawl.scraper.waimaoq.com/export/issuewire?token=MT0CM7y4tdFTFTm';
235 - $response = Http::get($url,['page'=>$this->param['page'],'pagesize'=>$this->param['row']]); 235 + $response = Http::get($url,['page'=>$this->page,'pagesize'=>$this->row]);
236 if ($response->successful()) { 236 if ($response->successful()) {
237 $result = $response->json(); 237 $result = $response->json();
238 } 238 }
@@ -207,7 +207,10 @@ class ImageController extends Controller @@ -207,7 +207,10 @@ class ImageController extends Controller
207 if($this->upload_location == 0){ 207 if($this->upload_location == 0){
208 $watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0); 208 $watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
209 $cosService = new CosService(); 209 $cosService = new CosService();
210 - $cosService->uploadFile($files,$this->path,$fileName,false,$watermarkOptions); 210 + $res = $cosService->uploadFile($files,$this->path,$fileName,false,$watermarkOptions);
  211 + if($res === false){
  212 + $this->response('上传失败,请重新上传',Code::SYSTEM_ERROR);
  213 + }
211 }else{ 214 }else{
212 //TODO::上传亚马逊 215 //TODO::上传亚马逊
213 $amazonS3Service = new AmazonS3Service(); 216 $amazonS3Service = new AmazonS3Service();
@@ -48,24 +48,30 @@ class CosService @@ -48,24 +48,30 @@ class CosService
48 // 如果不是 Base64 流文件,处理为普通文件上传 48 // 如果不是 Base64 流文件,处理为普通文件上传
49 $Body = $binary ? $files : fopen($files->getRealPath(), 'r'); 49 $Body = $binary ? $files : fopen($files->getRealPath(), 'r');
50 } 50 }
51 - $options = [  
52 - 'Bucket' => $cos['bucket'],  
53 - 'Key' => $key,  
54 - 'Body' => $Body,  
55 - ];  
56 - //水印  
57 - if ($watermarkOptions) {  
58 - $options['PicOperations'] = json_encode([  
59 - 'is_pic_info' => 1,  
60 - 'rules' => [  
61 - [  
62 - 'fileid' => $key, // 使用相同的文件名保存  
63 - 'rule' => $watermarkOptions, 51 + try {
  52 + $options = [
  53 + 'Bucket' => $cos['bucket'],
  54 + 'Key' => $key,
  55 + 'Body' => $Body,
  56 + ];
  57 + //水印
  58 + if ($watermarkOptions) {
  59 + $options['PicOperations'] = json_encode([
  60 + 'is_pic_info' => 1,
  61 + 'rules' => [
  62 + [
  63 + 'fileid' => $key, // 使用相同的文件名保存
  64 + 'rule' => $watermarkOptions,
  65 + ]
64 ] 66 ]
65 - ]  
66 - ], true); 67 + ], true);
  68 + }
  69 + $res = $cosClient->putObject($options);
  70 + @file_put_contents(storage_path('logs/upload_images'), var_export($res, true) . PHP_EOL, FILE_APPEND);
  71 + }catch (\Exception $e){
  72 + @file_put_contents(storage_path('logs/upload_images'), var_export($e->getMessage(), true) . PHP_EOL, FILE_APPEND);
  73 + return false;
67 } 74 }
68 - $res = $cosClient->putObject($options);  
69 return $key; 75 return $key;
70 } 76 }
71 77