/**
* 处理图片上传oss
* @param array $imgUrlArr
* @return array|bool
*/
public static function saveOssImg($imgUrlArr = []){
if(!$imgUrlArr) return false;
$newUrlArr = [];
$targetDir = 'images/'.self::getRandomString(2);
foreach($imgUrlArr as $k=>$v){
//如果已经上传oss过,则返回
if(strpos($v, 's1.zhongguomayun.com')!==false) return false;
$newUrl = '';
try{
$imgName = time().rand(1,999).'.'.self::getSuffix($v);
$targetName = $targetDir.'/'.$imgName;
$newUrl = config('app.upload_url').$targetName;
$client =new Client();
$data = $client->request('get',$v)->getBody()->getContents();
Storage::disk('local')->put($imgName,$data);
OSS::publicUpload(config('app.oss_bucket'),$targetName,storage_path('app/'.$imgName));
unlink(storage_path('app/'.$imgName));
}catch (RequestException $e){
}
$newUrlArr[] = $newUrl;
}
return $newUrlArr;
}