作者 刘锟

update

@@ -192,7 +192,7 @@ if (!function_exists('curl_c')) { @@ -192,7 +192,7 @@ if (!function_exists('curl_c')) {
192 if($http_code == 200){ 192 if($http_code == 200){
193 return $is_array ? json_decode($content, true) : $content; 193 return $is_array ? json_decode($content, true) : $content;
194 }else{ 194 }else{
195 - return $http_code; 195 + return false;
196 } 196 }
197 } 197 }
198 } 198 }
@@ -132,9 +132,18 @@ class CosService @@ -132,9 +132,18 @@ class CosService
132 ], 132 ],
133 ]); 133 ]);
134 134
135 - try {  
136 - $body = $body_str ?:curl_c($file_url,false);  
137 - }catch (\Exception $e){ 135 + if(empty($body_str)){
  136 + try {
  137 + $body_str = curl_c($file_url,false);
  138 + if(!$body_str){
  139 + $body_str = file_get_contents($file_url);
  140 + }
  141 + }catch (\Exception $e){
  142 + $body_str = '';
  143 + }
  144 + }
  145 +
  146 + if(!$body_str){
138 return ''; 147 return '';
139 } 148 }
140 149
@@ -142,7 +151,7 @@ class CosService @@ -142,7 +151,7 @@ class CosService
142 $cosClient->putObject([ 151 $cosClient->putObject([
143 'Bucket' => $cos['bucket'], 152 'Bucket' => $cos['bucket'],
144 'Key' => $key, 153 'Key' => $key,
145 - 'Body' => $body, 154 + 'Body' => $body_str,
146 ]); 155 ]);
147 return $key; 156 return $key;
148 }catch (\Exception $e){ 157 }catch (\Exception $e){