|
- <?php
-
- namespace App\Http\Controllers\Web\Image;
-
- use App\Exceptions\AppCommonException;
- use App\Http\Controllers\Web\WebController;
- use App\Kintone\KintoneAccess;
- use Illuminate\Http\Request;
- use Illuminate\Http\Response;
-
- abstract class ImageController extends WebController
- {
-
- public function name(): string
- {
- return "画像取得";
- }
-
- public function description(): string
- {
- return "KINTONEから画像を取得する";
- }
-
-
- public function __construct(protected ImageParam $param)
- {
- parent::__construct();
- $this->middleware('auth:sanctum');
- }
-
- protected function run(Request $request): Response
- {
- try {
-
- $id = $request->route('id');
- if (!$id) {
- throw new AppCommonException("パラメータ不正");
- }
- $access = $this->getAccess();
- $file = $access->fileGet($id);
- return response($file->body(), 200, [
- 'Content-Length' => $file->header('Content-Length'),
- 'Content-Type' => $file->header('Content-Type'),
- ]);
- } catch (Exception $e) {
- return response();
- }
- }
-
- abstract protected function getAccess(): KintoneAccess;
- }
|