Fixes for #8732 - Flysystem paths, migrator script

This commit is contained in:
snipe 2020-11-12 21:46:06 -08:00
parent c7d752fb65
commit 9db191f0b2
3 changed files with 29 additions and 28 deletions

View file

@ -47,33 +47,33 @@ class MoveUploadsToNewDisk extends Command
}
$delete_local = $this->argument('delete_local');
$public_uploads['accessories'] = glob('storage/app/public/accessories'."/*.*");
$public_uploads['assets'] = glob('storage/app/public/assets'."/*.*");
$public_uploads['avatars'] = glob('storage/app/public/avatars'."/*.*");
$public_uploads['categories'] = glob('storage/app/public/categories'."/*.*");
$public_uploads['companies'] = glob('storage/app/public/companies'."/*.*");
$public_uploads['components'] = glob('storage/app/public/components'."/*.*");
$public_uploads['consumables'] = glob('storage/app/public/consumables'."/*.*");
$public_uploads['departments'] = glob('storage/app/public/departments'."/*.*");
$public_uploads['locations'] = glob('storage/app/public/locations'."/*.*");
$public_uploads['manufacturers'] = glob('storage/app/public/manufacturers'."/*.*");
$public_uploads['suppliers'] = glob('storage/app/public/suppliers'."/*.*");
$public_uploads['assetmodels'] = glob('storage/app/public/models'."/*.*");
$public_uploads['accessories'] = glob('public/accessories'."/*.*");
$public_uploads['assets'] = glob('public/assets'."/*.*");
$public_uploads['avatars'] = glob('public/avatars'."/*.*");
$public_uploads['categories'] = glob('public/categories'."/*.*");
$public_uploads['companies'] = glob('public/companies'."/*.*");
$public_uploads['components'] = glob('public/components'."/*.*");
$public_uploads['consumables'] = glob('public/consumables'."/*.*");
$public_uploads['departments'] = glob('public/departments'."/*.*");
$public_uploads['locations'] = glob('public/locations'."/*.*");
$public_uploads['manufacturers'] = glob('public/manufacturers'."/*.*");
$public_uploads['suppliers'] = glob('public/suppliers'."/*.*");
$public_uploads['assetmodels'] = glob('public/models'."/*.*");
// iterate files
foreach($public_uploads as $public_type => $public_upload)
{
$type_count = 0;
$this->info("\nThere are ".count($public_upload).' PUBLIC '.$public_type.' files.');
$this->info("- There are ".count($public_upload).' PUBLIC '.$public_type.' files.');
for ($i = 0; $i < count($public_upload); $i++) {
$type_count++;
$filename = basename($public_upload[$i]);
try {
Storage::disk('public')->put($public_type.'/'.$filename, file_get_contents($public_upload[$i]));
$new_url = Storage::disk('public')->url($public_type.'/'.$filename, $filename);
Storage::disk('public')->put('uploads/'.public_type.'/'.$filename, file_get_contents($public_upload[$i]));
$new_url = Storage::disk('public')->url('uploads/'.$public_type.'/'.$filename, $filename);
$this->info($type_count.'. PUBLIC: '.$filename.' was copied to '.$new_url);
} catch (\Exception $e) {
\Log::debug($e);
@ -84,15 +84,16 @@ class MoveUploadsToNewDisk extends Command
}
$logos = glob('public/uploads'."/setting*.*");
$this->info("\nThere are ".count($logos).' files that might be logos.');
$logos = glob("public/uploads/setting*.*");
$this->info("- There are ".count($logos).' files that might be logos.');
$type_count = 0;
for ($l = 0; $l <= count($logos); $l++) {
foreach ($logos as $logo) {
$this->info($logo);
$type_count++;
$filename = basename($logos[$l]);
$new_url = Storage::disk('public')->url($logos[$l], file_get_contents($public_upload[$l]));
$this->info($type_count.'. LOGO: '.$filename.' was copied to '.$new_url);
$filename = basename($logo);
Storage::disk('public')->put('uploads/'.$filename, file_get_contents($logo));
$this->info($type_count.'. LOGO: '.$filename.' was copied to '.env('PUBLIC_AWS_URL').'/uploads/'.$filename);
}
$private_uploads['assets'] = glob('storage/private_uploads/assets'."/*.*");
@ -107,8 +108,7 @@ class MoveUploadsToNewDisk extends Command
foreach($private_uploads as $private_type => $private_upload)
{
$this->info("\nThere are ".count($private_upload).' PRIVATE '.$private_type.' files.');
// $this->info(print_r($private_upload, true));
$this->info("- There are ".count($private_upload).' PRIVATE '.$private_type.' files.');
$type_count = 0;
for ($x = 0; $x < count($private_upload); $x++) {

View file

@ -49,7 +49,8 @@ class ImageUploadRequest extends Request
$type = strtolower(class_basename(get_class($item)));
if (is_null($path)) {
$path = str_plural($type);
$path = 'uploads/';
$path .= str_plural($type);
if ($type == 'assetmodel') {
$path = 'models';

View file

@ -731,14 +731,14 @@
@if ($asset->image)
<div class="col-md-12 text-center" style="padding-bottom: 15px;">
<a href="{{ url('/') }}/uploads/assets/{{ $asset->image }}" data-toggle="lightbox">
<img src="{{ url('/') }}/uploads/assets/{{{ $asset->image }}}" class="assetimg img-responsive" alt="{{ $asset->getDisplayNameAttribute() }}">
<a href="{{ Storage::disk('public')->url('uploads/assets/'. $asset->image) }}" data-toggle="lightbox">
<img src="{{ Storage::disk('public')->url('uploads/assets/'. $asset->image) }}" class="assetimg img-responsive" alt="{{ $asset->getDisplayNameAttribute() }}">
</a>
</div>
@elseif (($asset->model) && ($asset->model->image!=''))
<div class="col-md-12 text-center" style="padding-bottom: 15px;">
<a href="{{ url('/') }}/uploads/models/{{ $asset->model->image }}" data-toggle="lightbox">
<img src="{{ url('/') }}/uploads/models/{{ $asset->model->image }}" class="assetimg img-responsive" alt="{{ $asset->getDisplayNameAttribute() }}">
<a href="{{ Storage::disk('public')->url('uploads/models/'.$asset->model->image) }}" data-toggle="lightbox">
<img src="{{ Storage::disk('public')->url('uploads/models/'.$asset->model->image) }}" class="assetimg img-responsive" alt="{{ $asset->getDisplayNameAttribute() }}">
</a>
</div>
@endif