使用JavaScript或JQuery从cloudinary获取图像列表

Get list of images from cloudinary using JavaScript or JQuery

本文关键字:获取 图像 列表 cloudinary JavaScript JQuery 使用      更新时间:2023-09-26

我已经根据这篇文章尝试了所有可能的代码,但代码给了我以下错误

XMLHttpRequest cannot load https://api.cloudinary.com/cloud_name/resources/image. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access.

代码(1)

$.get('https://app_key:app_secret@api.cloudinary.com/cloud_name/resources/image');

代码(2)

$.get('https://api.cloudinary.com/cloud_name/resources/image');

对于这两种情况,它都无法进行身份验证。

注意:我没有使用任何服务器端编程。请给我任何客户端解决方案/代码。

通过$.get(...),我知道您在客户端执行此调用(jQuery代码)。这意味着你将向用户展示你的帐户的api_secret,他们只需简单地"查看源代码"即可获得你的Cloudinary帐户凭据,然后他们就可以完全控制你的帐户,包括上传、重命名甚至删除资源。由于您可能不希望发生这种情况,您应该只在服务器端执行此操作,或者使用客户端(未签名)方法返回共享某个标记的所有资源。有关详细信息:https://support.cloudinary.com/hc/en-us/articles/203189031-How-to-retrieve-a-list-of-all-resources-sharing-the-same-tag-