Open DmitrySidorenkoShim opened 2 weeks ago
This seems to be an issue with the Eloquent Driver's implementation of the asset stuff.
I don't see the "This container is empty" error when using flat-files, but I do as soon as I switch to the Eloquent Driver.
Moving this issue to the eloquent-driver
repository.
What gets populated in your assets_meta table? Did you try running the sync command?
What gets populated in your assets_meta table? Did you try running the sync command?
here is what I have in assets_meta
in database:
<id> cloudinary / sample.jpg sample jpg sample.jpg {"data": []} null 2024-08-28 13:30:11 2024-08-28 13:30:11
may sound stupid but sorry I didn't heart about any sync command
You can read about it here - https://github.com/statamic/eloquent-driver?tab=readme-ov-file#syncing-assets If you are using an existing file system it will populate it with assets already added.
@ryanmitchell thanks for the quick response
I will try this php please eloquent:sync-assets
sync command
is it going through all asset containers and synchronizing files for discs they using? and the same for Cloudinary storage disk if I have asset container?
Yes it adds any pre-existing files to the database, and as the eloquent driver uses the database to build the folder list it will also then show you any folders.
there are looks like some issues with the command I tried it on the dev server, and it is just frozen on this:
for the last 20 mins or so... 🤔 are you using chunking? because we have around 62 thousand of images there
and I tried the command locally (I have there my dev Cloudinary account credentials) it was synced but not correctly
see hightailed entries (duplicates with wrong extensions)
it might be because you are doing something like:
$ext = Str::afterLast($path, '.');
instead of something like:
$ext1 = File::extension(\Illuminate\Support\Facades\Storage::disk('cloudinary')->path($uri));
could it be possible? 😌
Yes it is chunking where possible - if you are finding issues on your install please feel free to open a PR with the changes required.
@ryanmitchell
excuse me if I was not polite in any of my messages and thank you for your quick response you moved me from dead point 👍
ok, sadly I couldn't make sync command working with Cloudinary... (I also had no much time for this, doing this in my free time) the main issue is because of Cloudinary return a list with paths without extensions
@ryanmitchell can you maybe point to the place (a class and method) where the package gets an extension for Asset, please? 🙏 it can help to get further 😌
What do you mean an extension for asset? You can bind your own model and class (see the config) or you can bind your own AssetContainerContents - similar to how we do: https://github.com/statamic/eloquent-driver/blob/38371abc8dd58189b221e2efa136ef44a1468d79/src/ServiceProvider.php#L262-L264
@duncanmcclean did some digging on this and as you said the Flysystem driver doesn't seem to return an extension.
This unfortunately means we can't work with it - it may be worth raising an issue on that repo to see if they would consider including the extension in the same way other Flysystem adaptors do.
Bug description
I understand it is not directly a bug of Statamic itself but maybe someone can help me with this issue
so, in 'Assets' if you have 'Cloudinary' asset container and any folders in Cloudinary like 'auto mapping folder' and other nested folders in it loading of a list takes too much time, and at the end id shows 'The container is empty'
I thought it is an issue of Cloudinary itself but it works perfectly without any folders
Cloudinary package is only as flysystem disk driver and it does return a list of all files and directories from Cloudinary I also tried all variants of data in
asset_meta
trying to make it workHow to reproduce
So, install yoelpc4/laravel-cloudinary (I don't know why, but the official package cloudinary-labs/cloudinary-laravel is not fully working in this case) Fill out
.env
credentials:Register cloudinary driver configuration in
config/filesystems.php
at disks section (example in the package readme) In Cloudinary 'Upload Presets' add 'asset folder', for example: 'some/images'After all this setup is done goto Statamic Assets, create a new asset container 'Cloudinary' which uses 'cloudinary' disk and upload some sample.jpg (on this step Statamic will show an error " Hochladen fehlgeschlagen. Die Datei ist möglicherweise größer als von deinem Server erlaubt. " ["Upload failed. The file size may be larger than your server allows."]) the image is successfully uploaded to cloudinary though check the image is in the folder in Cloudinary something like: https://res.cloudinary.com/.../image/upload/v1.../some/images/sample.jpg and it is in
asset_meta
in databasebut after this there is no chance to see it in Statamic
any help on this would be appreciated 🙏
Logs
No response
Environment
Installation
Existing Laravel app
Additional details
I don't know if it is important but I have tried this:
like you have it in \Statamic\Assets\AssetContainerContents::all() in $files I have a full list of files and directories from Cloudinary
as I wrote, any help would be greatly appreciated