How do I get a list of my images from cloudinary f

2020-02-14 03:15发布

问题:

Using the cloudinary API I can get a list of images by GETting the following URL:

https://API_KEY:API_SECRET@api.cloudinary.com/v1_1/CLOUD_NAME/resources/image/upload

However, using this from client-side JavaScript would expose my account's API key and secret.

It seems like getting a list of images should be possible without exposing my account's credentials.

I've looked at the Cloudinary AngularJS client, which has a sample project that implements a slideshow of photos in an account. From what I can tell, this project uses the following line to get a list of photos in the cloudinary account

var url = $.cloudinary.url('myphotoalbum', {format: 'json', type: 'list'});

But I can't get this call to return anything.

The cloudinary JQuery documentation does not describe the syntax for $.cloudinary.url(); the only resource I've found is on the Cloudinary JQuery Github Page, which states that

$.cloudinary.url(public_id, options) // Returns a cloudinary URL based on your on your configuration and the given options.

What is public_id? What are the options?

回答1:

Browsing through all of your resources indeed require using the secured Admin API. This indeed requires using your api_secret which should not be revealed in your client-side code. However, Cloudinary supports returning a list of all images/raw-files sharing a certain tag. The response is a JSON snippet which is automatically updated and cached for 1 hour at the CDN.

The cloudinary.url API generates a URL of the specified parameters. So when using:

var url = $.cloudinary.url('myphotoalbum', {format: 'json', type: 'list'});

this generates a Cloudinary URL, something like the following:

http://res.cloudinary.com/<your_cloud_name>/image/list/myphotoalbum.json

This URL returns a JSON of all resources in your account sharing the 'myphotoalbum' tag.



回答2:

Read documentation link http://support.cloudinary.com/hc/en-us/articles/203189031-How-to-retrieve-a-list-of-all-resources-sharing-the-same-tag-

I did uncheck the 'Resource list' under "Security > Restricted image types". Then I could able to see the image list.