ajout app
This commit is contained in:
1462
SNIPE-IT/app/Helpers/Helper.php
Normal file
1462
SNIPE-IT/app/Helpers/Helper.php
Normal file
File diff suppressed because it is too large
Load Diff
25
SNIPE-IT/app/Helpers/StorageHelper.php
Normal file
25
SNIPE-IT/app/Helpers/StorageHelper.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class StorageHelper
|
||||
{
|
||||
public static function downloader($filename, $disk = 'default')
|
||||
{
|
||||
if ($disk == 'default') {
|
||||
$disk = config('filesystems.default');
|
||||
}
|
||||
switch (config("filesystems.disks.$disk.driver")) {
|
||||
case 'local':
|
||||
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?
|
||||
|
||||
default:
|
||||
return Storage::disk($disk)->download($filename);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user