Yes, it is possible to mask URLs with Laravel. One way to achieve this is by using route parameters and a controller method to handle the request.
First, define a route that includes a parameter for the image ID:
Route::get('/download/{id}', 'DownloadController@downloadImage');
Next, create a controller method that retrieves the image based on the ID and returns it as a download:
public function downloadImage($id)
{
$image = Image::find($id);
$path = storage_path('app/' . $image->path);
return response()->download($path);
}
In this example, the image is retrieved from a database using the ID parameter. The image path is then used to generate a download response using Laravel's response()->download() method.
Finally, update the image URLs in your application to use the new route:
<a href="{{ route('downloadImage', ['id' => $image->id]) }}">Download Image</a>
This will generate a URL like https://example.com/download/5c50f2b2-33c8-496b-9f97-f5025e58aff7 that will be handled by the downloadImage method in the DownloadController.