Actually force the download in S3

This commit is contained in:
snipe
2026-03-27 15:43:28 +00:00
parent c89e14ae52
commit 3b875ce6ec
+8 -3
View File
@@ -2,7 +2,6 @@
namespace App\Helpers;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
@@ -20,7 +19,14 @@ class StorageHelper
return response()->download(Storage::disk($disk)->path($filename)); // works for PRIVATE or public?!
case 's3':
return redirect()->away(Storage::disk($disk)->temporaryUrl($filename, now()->addMinutes(5))); // works for private or public, I guess?
Storage::disk($disk)->temporaryUrl(
$filename,
now()->addMinutes(5),
[
'ResponseContentType' => 'application/octet-stream',
'ResponseContentDisposition' => 'attachment; filename=download-file',
]
);
default:
return Storage::disk($disk)->download($filename);
@@ -119,5 +125,4 @@ class StorageHelper
return null;
}
}