<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Files;
use App\Exceptions\GlobalException;

class FileController extends Controller
{
    /**
     * 
     */
public function show($filename)
    {
        try {
            $path = storage_path('app/fileuploads/' . $filename);
            if (!file_exists($path)) {
                throw new GlobalException("Archivo no existente");
            }
            $file = file_get_contents($path);
            $type = mime_content_type($path);
            return response($file, 200)->header("Content-Type", $type);    
        } catch (Throwable $th) {
            throw new GlobalException($th->getMessage());
        }
    }


    

}