作者 lyh

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

@@ -326,4 +326,22 @@ class FileController @@ -326,4 +326,22 @@ class FileController
326 $data = ['file_download'=>url('a/download_files?path='.$info['path'])]; 326 $data = ['file_download'=>url('a/download_files?path='.$info['path'])];
327 $this->response('success',Code::SUCCESS,$data); 327 $this->response('success',Code::SUCCESS,$data);
328 } 328 }
  329 +
  330 + /**
  331 + * 根据远程图片地址上传
  332 + * @param $file_url
  333 + * @return JsonResponse
  334 + * @author Akun
  335 + * @date 2023/09/21 9:40
  336 + */
  337 + public function upRemoteUrl($file_url){
  338 + $ext = explode('.',$file_url);
  339 + $fileName = uniqid().rand(10000,99999).'.'.end($ext);
  340 +
  341 + //同步数据到cos
  342 + $cosService = new CosService();
  343 + $cosService->uploadRemote($file_url,$this->path,$fileName);
  344 +
  345 + return $this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName));
  346 + }
329 } 347 }
@@ -62,5 +62,32 @@ class CosService @@ -62,5 +62,32 @@ class CosService
62 } 62 }
63 63
64 64
  65 + /**
  66 + * 根据远程图片地址上传
  67 + * @param $file_url
  68 + * @param $path
  69 + * @param $filename
  70 + * @return string
  71 + * @author Akun
  72 + * @date 2023/09/21 9:39
  73 + */
  74 + public function uploadRemote($file_url,$path,$filename)
  75 + {
  76 + $cos = config('filesystems.disks.cos');
  77 + $cosClient = new Client([
  78 + 'region' => $cos['region'],
  79 + 'credentials' => [
  80 + 'secretId' => $cos['credentials']['secretId'],
  81 + 'secretKey' => $cos['credentials']['secretKey'],
  82 + ],
  83 + ]);
  84 + $key = $path.'/'.$filename;
  85 + $cosClient->putObject([
  86 + 'Bucket' => $cos['bucket'],
  87 + 'Key' => $key,
  88 + 'Body' => fopen($file_url, 'r'),
  89 + ]);
  90 + return $key;
  91 + }
65 92
66 } 93 }
@@ -363,4 +363,6 @@ Route::group([], function () { @@ -363,4 +363,6 @@ Route::group([], function () {
363 Route::any('/qrcode', [\App\Http\Controllers\Bside\LoginController::class, 'qrcode'])->name('qrcode'); 363 Route::any('/qrcode', [\App\Http\Controllers\Bside\LoginController::class, 'qrcode'])->name('qrcode');
364 Route::any('/globalSo_v6_login', [\App\Http\Controllers\Bside\LoginController::class, 'globalSo_v6_login'])->name('globalSo_v6_login'); 364 Route::any('/globalSo_v6_login', [\App\Http\Controllers\Bside\LoginController::class, 'globalSo_v6_login'])->name('globalSo_v6_login');
365 Route::any('/getWechatLoginInfo', [\App\Http\Controllers\Bside\LoginController::class, 'getWechatLoginInfo'])->name('getWechatLoginInfo'); 365 Route::any('/getWechatLoginInfo', [\App\Http\Controllers\Bside\LoginController::class, 'getWechatLoginInfo'])->name('getWechatLoginInfo');
  366 +
  367 + Route::post('/upload_remote', [\App\Http\Controllers\File\FileController::class, 'upRemoteUrl'])->name('remote_file_upload');
366 }); 368 });