mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Use Storage for file uploads (not model images)
This commit is contained in:
parent
a9fd9c9e59
commit
373885ebd1
|
@ -107,21 +107,18 @@ class AssetFilesController extends Controller
|
||||||
{
|
{
|
||||||
$asset = Asset::find($assetId);
|
$asset = Asset::find($assetId);
|
||||||
$this->authorize('update', $asset);
|
$this->authorize('update', $asset);
|
||||||
$destinationPath = config('app.private_uploads').'/imports/assets';
|
$rel_path = 'storage/private_uploads/assets';
|
||||||
|
|
||||||
// the asset is valid
|
// the asset is valid
|
||||||
if (isset($asset->id)) {
|
if (isset($asset->id)) {
|
||||||
$this->authorize('update', $asset);
|
$this->authorize('update', $asset);
|
||||||
|
|
||||||
$log = Actionlog::find($fileId);
|
$log = Actionlog::find($fileId);
|
||||||
$full_filename = $destinationPath.'/'.$log->filename;
|
if (file_exists(base_path().'/'.$rel_path.'/'.$log->filename)) {
|
||||||
if (file_exists($full_filename)) {
|
Storage::delete($rel_path.'/'.$log->filename);
|
||||||
\Log::debug('Trying to delete '.$full_filename);
|
|
||||||
Storage::delete($full_filename);
|
|
||||||
//unlink($destinationPath.'/'.$log->filename);
|
|
||||||
}
|
}
|
||||||
$log->delete();
|
$log->delete();
|
||||||
return redirect()->back()->with('success', trans('admin/hardware/message.deletefile.success'));
|
return redirect()->back()
|
||||||
|
->with('success', trans('admin/hardware/message.deletefile.success'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to the hardware management page
|
// Redirect to the hardware management page
|
||||||
|
|
|
@ -75,19 +75,19 @@ class LicenseFilesController extends Controller
|
||||||
public function destroy($licenseId = null, $fileId = null)
|
public function destroy($licenseId = null, $fileId = null)
|
||||||
{
|
{
|
||||||
$license = License::find($licenseId);
|
$license = License::find($licenseId);
|
||||||
$destinationPath = config('app.private_uploads').'/licenses';
|
|
||||||
|
|
||||||
// the license is valid
|
$rel_path = 'storage/private_uploads/licenses';
|
||||||
|
|
||||||
|
// the asset is valid
|
||||||
if (isset($license->id)) {
|
if (isset($license->id)) {
|
||||||
$this->authorize('edit', $license);
|
$this->authorize('update', $license);
|
||||||
$log = Actionlog::find($fileId);
|
$log = Actionlog::find($fileId);
|
||||||
$full_filename = $destinationPath.'/'.$log->filename;
|
if (file_exists(base_path().'/'.$rel_path.'/'.$log->filename)) {
|
||||||
if (file_exists($full_filename)) {
|
Storage::delete($rel_path.'/'.$log->filename);
|
||||||
Storage::delete($full_filename);
|
|
||||||
// unlink($destinationPath.'/'.$log->filename);
|
|
||||||
}
|
}
|
||||||
$log->delete();
|
$log->delete();
|
||||||
return redirect()->back()->with('success', trans('admin/licenses/message.deletefile.success'));
|
return redirect()->back()
|
||||||
|
->with('success', trans('admin/hardware/message.deletefile.success'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to the licence management page
|
// Redirect to the licence management page
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
"watson/validating": "^3.0"
|
"watson/validating": "^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"barryvdh/laravel-ide-helper": "^2.4",
|
||||||
"codeception/codeception": "^2.4",
|
"codeception/codeception": "^2.4",
|
||||||
"filp/whoops": "~2.0",
|
"filp/whoops": "~2.0",
|
||||||
"fzaninotto/faker": "~1.4",
|
"fzaninotto/faker": "~1.4",
|
||||||
|
@ -72,6 +73,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"post-update-cmd": [
|
||||||
|
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
|
||||||
|
"php artisan ide-helper:generate",
|
||||||
|
"php artisan ide-helper:meta"
|
||||||
|
],
|
||||||
"post-autoload-dump": [
|
"post-autoload-dump": [
|
||||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||||
"@php artisan package:discover"
|
"@php artisan package:discover"
|
||||||
|
|
Loading…
Reference in a new issue