如何从客户端JavaScript的cloudinary获取我的图像列表?

drs*_*drs 6 javascript cloudinary

使用cloudinary API我可以通过GET以下URL 获取图像列表:

https://API_KEY:API_SECRET@api.cloudinary.com/v1_1/CLOUD_NAME/resources/image/upload
Run Code Online (Sandbox Code Playgroud)

但是,从客户端JavaScript使用此方法会暴露我的帐户的API密钥和密钥.

似乎可以在不暴露我的帐户凭据的情况下获取图像列表.

我查看了Cloudinary AngularJS客户端,它有一个示例项目,可以在帐户中实现照片的幻灯片放映.据我所知,这个项目使用以下行来获取cloudinary帐户中的照片列表

var url = $.cloudinary.url('myphotoalbum', {format: 'json', type: 'list'});
Run Code Online (Sandbox Code Playgroud)

但我不能接到这个电话来回报任何东西.

该cloudinary jQuery的文档不描述语法$.cloudinary.url(); 我发现的唯一资源是Cloudinary JQuery Github Page,它说明了这一点

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

什么是public_id?有什么options?

小智 7

浏览所有资源确实需要使用安全的Admin API.这确实需要使用您api_secret的客户端代码中不应显示的内容.但是,Cloudinary支持返回共享特定标记的所有图像/原始文件的列表.响应是一个JSON片段,它会在CDN自动更新并缓存1小时.

的cloudinary.urlAPI生成指定参数的URL.所以使用时:

var url = $.cloudinary.url('myphotoalbum', {format: 'json', type: 'list'});
Run Code Online (Sandbox Code Playgroud)

这会生成一个Cloudinary URL,如下所示:

http://res.cloudinary.com/<your_cloud_name>/image/list/myphotoalbum.json
Run Code Online (Sandbox Code Playgroud)

此网址会返回您帐户中共享" myphotoalbum "标记的所有资源的JSON .


小智 5

阅读文档链接http://support.cloudinary.com/hc/en-us/articles/203189031-How-to-retrieve-a-list-of-all-resources-sharing-the-same-tag-

我确实没有选中“安全性>受限图像类型”下的“资源列表”。然后,我可以看到图像列表。