51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?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',
|
|
]);
|
|
}
|
|
}
|