Generate multiple avatar sizes for better performance loading and frugal traffic

This commit is contained in:
Čarodej
2021-11-03 16:28:14 +01:00
parent dc8ec5f20b
commit f139dbae08
30 changed files with 280 additions and 152 deletions

View File

@@ -3,8 +3,8 @@ namespace Domain\Files\Controllers\FileAccess;
use Gate;
use Illuminate\Http\Request;
use Domain\Files\Models\File;
use App\Http\Controllers\Controller;
use Domain\Files\Models\File as UserFile;
use Domain\Files\Actions\DownloadThumbnailAction;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
@@ -20,14 +20,16 @@ class GetThumbnailController extends Controller
string $filename,
): FileNotFoundException | StreamedResponse {
$file = UserFile::withTrashed()
->where('thumbnail', $filename)
$originalFileName = substr($filename, 3);
$file = File::withTrashed()
->where('basename', $originalFileName)
->firstOrFail();
if (! Gate::any(['can-edit', 'can-view'], [$file, null])) {
abort(403, 'Access Denied');
}
return ($this->downloadThumbnail)($file, $file->user_id);
return ($this->downloadThumbnail)($filename, $file);
}
}