mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Merge remote-tracking branch 'origin/develop'
# Conflicts: # app/Providers/AppServiceProvider.php # config/logging.php # config/services.php
This commit is contained in:
commit
ab092fd209
|
@ -39,7 +39,7 @@ class Handler extends ExceptionHandler
|
|||
public function report(Exception $exception)
|
||||
{
|
||||
if ($this->shouldReport($exception)) {
|
||||
Log::error($exception);
|
||||
\Log::error($exception);
|
||||
return parent::report($exception);
|
||||
}
|
||||
}
|
||||
|
|
23
app/Helpers/StorageHelper.php
Normal file
23
app/Helpers/StorageHelper.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ use App\Models\Actionlog;
|
|||
use App\Models\Asset;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Helpers\StorageHelper;
|
||||
|
||||
class AssetFilesController extends Controller
|
||||
{
|
||||
|
@ -86,7 +87,7 @@ class AssetFilesController extends Controller
|
|||
}
|
||||
return JsonResponse::create(["error" => "Failed validation: "], 500);
|
||||
}
|
||||
return Storage::download($file);
|
||||
return StorageHelper::downloader($file);
|
||||
}
|
||||
// Prepare the error message
|
||||
$error = trans('admin/hardware/message.does_not_exist', ['id' => $fileId]);
|
||||
|
|
|
@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Input;
|
|||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use App\Helpers\StorageHelper;
|
||||
|
||||
class LicenseFilesController extends Controller
|
||||
{
|
||||
|
@ -143,18 +144,18 @@ class LicenseFilesController extends Controller
|
|||
|
||||
// We have to override the URL stuff here, since local defaults in Laravel's Flysystem
|
||||
// won't work, as they're not accessible via the web
|
||||
if (config('filesystems.default') == 'local') {
|
||||
return Storage::download($file);
|
||||
if (config('filesystems.default') == 'local') { // TODO - is there any way to fix this at the StorageHelper layer?
|
||||
return StorageHelper::downloader($file);
|
||||
} else {
|
||||
if ($download != 'true') {
|
||||
\Log::debug('display the file');
|
||||
if ($contents = file_get_contents(Storage::url($file))) {
|
||||
if ($contents = file_get_contents(Storage::url($file))) { // TODO - this will fail on private S3 files or large public ones
|
||||
return Response::make(Storage::url($file)->header('Content-Type', mime_content_type($file)));
|
||||
}
|
||||
return JsonResponse::create(["error" => "Failed validation: "], 500);
|
||||
}
|
||||
|
||||
return Storage::download($file);
|
||||
return StorageHelper::downloader($file);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ use Image;
|
|||
use Input;
|
||||
use Redirect;
|
||||
use Response;
|
||||
use App\Helpers\StorageHelper;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Settings for
|
||||
|
@ -1091,7 +1092,7 @@ class SettingsController extends Controller
|
|||
|
||||
if (! config('app.lock_passwords')) {
|
||||
if (Storage::exists($path . '/' . $filename)) {
|
||||
return Storage::download($path . '/' . $filename);
|
||||
return StorageHelper::downloader($path . '/' . $filename);
|
||||
} else {
|
||||
// Redirect to the backup page
|
||||
return redirect()->route('settings.backups.index')->with('error', trans('admin/settings/message.backup.file_not_found'));
|
||||
|
|
|
@ -117,7 +117,7 @@ class UserFilesController extends Controller
|
|||
|
||||
$log = Actionlog::find($fileId);
|
||||
$file = $log->get_src('users');
|
||||
return Response::download($file);
|
||||
return Response::download($file); //FIXME this doesn't use the new StorageHelper yet, but it's complicated...
|
||||
}
|
||||
// Prepare the error message
|
||||
$error = trans('admin/users/message.user_not_found', ['id' => $userId]);
|
||||
|
|
|
@ -100,6 +100,9 @@ return [
|
|||
* The directory where the temporary files will be stored.
|
||||
*/
|
||||
'temporary_directory' => storage_path('app/backup-temp'),
|
||||
|
||||
//'encryption' => \ZipArchive::EM_AES_256,
|
||||
'encryption' => null,
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
@ -15,7 +15,7 @@ $config = [
|
|||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
'default' => 'stack',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -59,6 +59,7 @@ $config = [
|
|||
'level' => env('APP_LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
|
@ -99,4 +100,4 @@ if ((env('APP_ENV')=='production') && env('ROLLBAR_TOKEN')) {
|
|||
}
|
||||
|
||||
|
||||
return $config;
|
||||
return $config;
|
||||
|
|
Loading…
Reference in a new issue