Commit e73e4a4e e73e4a4eb5f20b29a03a3cb303315294d49f0b57 by lemon

文件上传cos

1 parent 3e213fd2
......@@ -2,6 +2,7 @@
namespace App\Services;
use App\Helper\AesEncrypt;
use App\Helper\CosHelper;
use App\Helper\ErrorCode;
use App\Helper\RedisClient;
......@@ -303,7 +304,32 @@ class PropertyTrackService extends Service
Log::info(__METHOD__, ['msg'=>$throwable->getMessage()]);
return Response::error();
}
}
/**
* @return \Illuminate\Http\JsonResponse|mixed
*/
public function getCosToken()
{
$client = new \GuzzleHttp\Client([
'base_uri' => env('resource_url'),
'timeout' => 3.0,
]);
try {
$response = $client->post($this->request->getRequestUri(), [
'json' => $this->request->only(['dir', 'material']),
]);
$respArr = json_decode($response->getBody()->getContents(), true);
$respArr['msg'] = $respArr['message'];
unset($respArr['message']);
return response()->json($respArr, 200);
} catch (\Throwable $throwable) {
return Response::error(ErrorCode::SERVER_ERROR, $throwable->getMessage());
}
}
}
......