This commit is contained in:
50
api/app/Http/Controllers/Regulacao/UploadController.php
Normal file
50
api/app/Http/Controllers/Regulacao/UploadController.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Regulacao;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Regulacao\UploadService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class UploadController extends Controller
|
||||
{
|
||||
protected $modulo = 'regulacao';
|
||||
protected $funcionalidade = 'upload';
|
||||
|
||||
public function show()
|
||||
{
|
||||
return response()->json(UploadService::show(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
return response()->json(UploadService::store(), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function download($id)
|
||||
{
|
||||
$response = UploadService::download($id);
|
||||
|
||||
$tipoMime = mime_content_type($response['arquivo']);
|
||||
$headers = [
|
||||
'Content-Type' => $tipoMime,
|
||||
];
|
||||
|
||||
return response()->download($response['arquivo'], $response['nome'], $headers);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return response()->json(UploadService::destroy($id), Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function view($id)
|
||||
{
|
||||
$fileData = UploadService::view($id);
|
||||
|
||||
return response()->file($fileData['path'], [
|
||||
'Content-Type' => $fileData['mimeType'],
|
||||
'Cache-Control' => 'public, max-age=86400',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user