next-cloudinary icon indicating copy to clipboard operation
next-cloudinary copied to clipboard

How to list assets from Cloudinary on a page

Open imaxisXD opened this issue 1 year ago • 1 comments

How can a user get the images in systematic manner that they are stored

For example, I have uploaded images in a folder in order 1.png, 2.png etc

Now on the frontend, I want to get the images in the order that I stored

for(i=0;i<7;i++) { Image src = {/image/${i}.png } }

How can we achieve this ?

imaxisXD avatar Feb 29 '24 20:02 imaxisXD

hey @imaxisXD typically people will use the Node.js SDK (or backend SDK) to fetch resources serverside and feed them to the UI, such as:

  • an endpoint: https://github.com/cloudinary-community/cloudinary-examples/blob/main/examples/nextjs-route-handlers-upload/src/app/api/resources/route.ts
  • server component: https://github.com/cloudinary-community/cloudinary-examples/blob/main/examples/nextjs-server-actions-upload/src/app/page.tsx#L26

there's also a feature that allows you to fetch a list of assets by tag from an endpoint, which you can do clientside, but the assets require the tag and you need to enable that feature under the Security tab of settings

https://cloudinary.com/documentation/list_assets

colbyfayock avatar Feb 29 '24 20:02 colbyfayock