【问题标题】:How can I get image url of all the uploaded images from the cloudinary server?如何从 cloudinary 服务器获取所有上传图片的图片 url?
【发布时间】:2019-03-11 16:30:36
【问题描述】:

我已成功将 6 张图片一张一张上传到 Cloudinary。现在我想获取所有图片的 URL。如何进入安卓手机客户端?

我正在使用下面的代码。

 List<String> imageList = new ArrayList<>();
    Map config = ObjectUtils.asMap(

            "cloud_name", "shank",

            "api_key", "644617911542992",

            "api_secret", "oW3bQk8luOT9UlEkRsH21KoQkxY");

    Cloudinary cloudinary = new Cloudinary(config);

    Api api = cloudinary.api();

    JSONObject outerObject = null;

    String jsonNext = null;

    boolean ifWeHaveMoreResources = true;

    while (ifWeHaveMoreResources) {
        try {

            outerObject = new JSONObject(api.resources(ObjectUtils.asMap("max_results", 10, "next_cursor", jsonNext)));

            if (outerObject.has("next_cursor")) {

                jsonNext = outerObject.get("next_cursor").toString();

                ifWeHaveMoreResources = true;

            } else {

                ifWeHaveMoreResources = false;

            }

            JSONArray jsonArray = outerObject.getJSONArray("resources");

            for (int i = 0, size = jsonArray.length(); i < size; i++) {

                JSONObject objectInArray = jsonArray.getJSONObject(i);

                String public_id = objectInArray.get("public_id").toString();

                String url = objectInArray.get("secure_url").toString();

                imageList.add(url);

            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

但它给出了例外。

java.lang.Exception: Administration API is not supported for mobile applications

请帮我解决这个问题。

【问题讨论】:

  • 请发布您的代码以检查您的代码有什么问题
  • @SandeepParish 我在这里使用代码 sn-p [support.cloudinary.com/hc/en-us/community/posts/…
  • 无论您使用什么代码 sn-p 都没关系,也许您缺少某些东西或其他任何东西
  • @SandeepParish 我编辑了我的问题。现在你可以检查我的代码了。
  • Check This,它会帮助你,如果有任何问题,请告诉我

标签: android cloudinary


【解决方案1】:

java.lang.Exception:移动应用程序不支持管理 API

出于安全原因,Admin API 不适用于 Android 等客户端 SDK。

您应该使用某种代理服务器来调用 Cloudinary(例如,您可以使用 Cloud Functions for Firebase

【讨论】:

    猜你喜欢
    • 2020-03-02
    • 2021-10-27
    • 2016-03-10
    • 2011-07-23
    • 1970-01-01
    • 2016-09-20
    • 2019-01-02
    • 1970-01-01
    • 2017-06-02
    相关资源
    最近更新 更多