Assets returned by API 'resources' method not match folder content
Hi,
we're using Cloudinary API resources method to list all assets in folder (by using prefix)
const folder = ...
For example we use media library widget to crop original image (by selecting 'crop original image').
After this operation we proceed to delete all assets in the folder.
(in media library website explorer and in media library widget it appears correctly empty)
If we call 'resources' API method instead, it keeps showing also deleted assets
even if the folder is empty.
Here an example of returned asset:
{
asset_id: '5f8b81826875c2de1d5199f0be0c7a9c',
public_id: 'test/5ebe8f4fc23e600c5a7769db/dsp4vs3jueqmr62aby3b',
format: 'jpg',
version: 1590409229,
resource_type: 'image',
type: 'upload',
placeholder: true,
created_at: '2020-05-25T11:08:20Z',
bytes: 0,
width: 339,
height: 325,
backup: true,
access_mode: 'public',
url:
'http://res.cloudinary.com/autoinrete-com/image/upload/v1590409229/test/5ebe8f4fc23e600c5a7769db/dsp4vs3jueqmr62aby3b.jpg',
secure_url:
'https://res.cloudinary.com/autoinrete-com/image/upload/v1590409229/test/5ebe8f4fc23e600c5a7769db/dsp4vs3jueqmr62aby3b.jpg'
},
As we could notice, these assets have 'bytes':'0' and in our backend we are filtering on this property to exclude this kind of assets.
Can we have some information about this behaviour?
Thank you.
-
Hi,
The response to the Get Resources method of the Admin API is expected to return both 'active' and 'deleted' assets unlike the Media Library which shows 'active' assets only. You can indeed filter this response based on the 'bytes' value or 'placeholder' which will be True in such cases.
The reason this method returns deleted files is that you may choose to use the Restore method to restore them from backup.
You can find those assets in your Media Library by selecting the Advanced Search button (next to the magnifying glass), finding the 'types' dropdown and selecting 'Deleted Asset' from that. Please see screenshot below -
If you don't want to filter the results on your side on the 'bytes' or 'placeholder' values then you should consider using the Search API which also allows you to specify a 'prefix' but returns only 'active' assets by default (the relevant expression field is 'status').
0
Post is closed for comments.
Comments
1 comment