Add attachements directly in the filesystem
This commit is contained in:
parent
495936503d
commit
2bbd15f0f1
|
@ -34,14 +34,14 @@ class AttachmentsManager
|
||||||
*/
|
*/
|
||||||
const Videos = 'videos';
|
const Videos = 'videos';
|
||||||
|
|
||||||
|
private string $attachmentsDir = 'attachments';
|
||||||
|
|
||||||
private string $targetForFiles;
|
private string $targetForFiles;
|
||||||
|
|
||||||
private string $metadataFilePath;
|
private string $metadataFilePath;
|
||||||
|
|
||||||
private MetadataManager $manager;
|
private MetadataManager $manager;
|
||||||
|
|
||||||
private string $attachmentsDir = 'attachments';
|
|
||||||
|
|
||||||
private FilesystemAdapter $disk;
|
private FilesystemAdapter $disk;
|
||||||
|
|
||||||
private bool $isLoaded = false;
|
private bool $isLoaded = false;
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
namespace App\Classes\Traits\Repairs;
|
namespace App\Classes\Traits\Repairs;
|
||||||
|
|
||||||
|
use App\Classes\AttachmentsManager;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Intervention\Image\Laravel\Facades\Image;
|
use Intervention\Image\Laravel\Facades\Image;
|
||||||
|
use League\Flysystem\StorageAttributes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trait for AttachmentsManager
|
* Trait for AttachmentsManager
|
||||||
|
@ -18,6 +20,33 @@ private function repairImages()
|
||||||
{
|
{
|
||||||
$this->load();
|
$this->load();
|
||||||
|
|
||||||
|
$files = $this->disk->listContents(
|
||||||
|
sprintf(
|
||||||
|
'%s/%s/%s',
|
||||||
|
$this->bundle->getDataDir(),
|
||||||
|
$this->attachmentsDir,
|
||||||
|
AttachmentsManager::Images
|
||||||
|
),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
->filter(fn (StorageAttributes $attributes) => $attributes->isFile())
|
||||||
|
->map(fn (StorageAttributes $attributes) => $attributes->path())
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$content = $this->disk->get($file);
|
||||||
|
$filename = sprintf('%s/%s', AttachmentsManager::Images, pathinfo($file, PATHINFO_BASENAME));
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'contents' => $content,
|
||||||
|
'filename' => $filename,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->disk->delete($file);
|
||||||
|
|
||||||
|
$this->add($data);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->manager->get('files', []) as $ref => $data) {
|
foreach ($this->manager->get('files', []) as $ref => $data) {
|
||||||
$this->repairKnownImage($ref, $data);
|
$this->repairKnownImage($ref, $data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user