问题描述
使用cloudinary API,我可以通过 GET
设置以下URL来获取图像列表:
Using the cloudinary API I can get a list of images by GET
ting the following URL:
https://API_KEY:[email protected]/v1_1/CLOUD_NAME/resources/image/upload
但是,从客户端JavaScript中使用它会暴露我帐户的API密钥和机密。
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.
没有描述 $。cloudinary.url()
的语法;我找到的唯一资源是在上,该页面指出
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.
什么是 public_id
? 选项
是什么?
推荐答案
确实浏览所有资源需要使用安全的Admin API。这确实需要使用您的 api_secret
,该代码不应在客户端代码中显示。
但是,Cloudinary支持返回共享某个标签的所有图像/原始文件的列表。
响应是一个JSON代码段,该代码段会自动更新并在CDN上缓存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.
cloudinary.url
API生成指定参数的URL。因此,在使用时:
The cloudinary.url
API generates a URL of the specified parameters. So when using:
var url = $.cloudinary.url('myphotoalbum', {format: 'json', type: 'list'});
这会生成一个Cloudinary URL,如下所示:
this generates a Cloudinary URL, something like the following:
http://res.cloudinary.com/<your_cloud_name>/image/list/myphotoalbum.json
此URL返回您帐户中共享 myphotoalbum 标签的所有资源的JSON。
This URL returns a JSON of all resources in your account sharing the 'myphotoalbum' tag.
这篇关于如何通过客户端JavaScript从cloudinary获取我的图像列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!