mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-28 23:19:42 -08:00
23 lines
730 B
PHP
23 lines
730 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Helpers;
|
||
|
use Illuminate\Support\Facades\Storage;
|
||
|
|
||
|
class StorageHelper
|
||
|
{
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|