-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.php
30 lines (22 loc) · 1009 Bytes
/
routes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
use Illuminate\Routing\Controller;
Route::get('/backend/inerba/backup/{filename}', function($filename){
$user = BackendAuth::getUser();
if ($user && ( $user->is_superuser || $user->hasPermission([
'inerba.backup.download',
]))) {
$filename = is_null( config('laravel-backup.backup.name') ) ? $filename : config('laravel-backup.backup.name') . '/' . $filename;
// Download backup
$disk = \Storage::disk('sftp');
$stream = $disk->readStream($filename);
return \Response::stream(function() use($stream) {
fpassthru($stream);
}, 200, [
"Content-Type" => $disk->getMimetype($filename),
"Content-Length" => $disk->getSize($filename),
"Content-disposition" => "attachment; filename=\"" . basename($filename) . "\"",
]);
} else {
throw new ApplicationException('Non sei autorizzato ad eseguire questo comando!');
}
});