Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a list of my images from cloudinary from client-side JavaScript?

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

https://API_KEY:[email protected]/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?

like image 977
drs Avatar asked Jun 26 '14 13:06

drs


People also ask

How do I find my Cloudinary API URL?

You can view your base URLs and some sample URLs in the Account Details section in the Management Console. The base URL will also include your cloud name. For example, if your cloud name is 'demo', the base URLs will be: 'api.cloudinary.com/v1_1/demo/' - the base URL for accessing Cloudinary's secure API.

Are Cloudinary images public?

Public ID. Every asset uploaded to Cloudinary is assigned a unique identifier in the form of a Public ID, which is a URL-safe string that is used to reference the uploaded resource as well as for building dynamic delivery and transformation URLs.

What is https Cloudinary?

Cloudinary Platform Powering Your Media Developers and marketers use Cloudinary to quickly and easily create, manage and deliver their digital experiences across any browser, device and bandwidth. Digital Asset Management.


2 Answers

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.

like image 82
Itay Taragano Avatar answered Oct 20 '22 01:10

Itay Taragano


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.

like image 22
Raghava Kotekar Avatar answered Oct 20 '22 00:10

Raghava Kotekar