【问题标题】:View cloudinary images/vid through android app通过 android 应用查看 cloudinary 图像/vid
【发布时间】:2016-03-29 18:15:47
【问题描述】:

我已经在很多地方寻找关于如何或是否可以通过我正在尝试构建的 Android Studio 应用程序通过特定标签查看上传到 cloudinary 的图像的线索。

我能够通过用户实现上传选项,向图像添加标签和公共 ID,还检索这些信息,但我找不到任何关于如何查看这些图像的信息,例如我希望应用程序能够向上传图片的用户查看带有特定标签(用户名)的所有图片,并且可以删除它们吗?还可以查看其他用户上传的其他图片,没有其他权限。

有可能吗?怎么做?

我最终得到了这段代码,但遇到了问题;

             @Override
        public void onClick(View v) {

            new JsonTask().execute("http://res.cloudinary.com/cloudNAme/video/list/xxxxxxxxxxxxxxxxxxx.json");
           // uploadExtract();
        }
    });

 public class JsonTask extends AsyncTask<String ,String,String> {

    @Override
    protected String doInBackground(String... params) {
        HttpURLConnection connection = null;
        BufferedReader reader = null;
        try {
            URL url = new URL(params[0]);
            connection = (HttpURLConnection) url.openConnection();
            connection.connect();

            InputStream stream = connection.getInputStream();
            reader = new BufferedReader(new InputStreamReader(stream));

            StringBuffer buffer = new StringBuffer();

            String line = "";
            while ((line = reader.readLine()) != null) {
                buffer.append(line);
            }
            return buffer.toString();


        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (connection != null) {
                connection.disconnect();


            }
            try {
                if (reader != null) {
                    reader.close();

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

            }
        }
        return null;
    }

在日志中我得到以下信息;

03-28 12:36:14.726 20333-21459/net.we4x4.we4x4 W/System.err: java.io.FileNotFoundException: http://res.cloudinary.com/we4x4/video/list/3c42f867-8c3a-423b-89e8-3fb777ab76f8.json

我不确定我对方法的理解是否正确,或者我做错了什么?因为在 Admin API Docs 中。或对 HTML 请求的语法以及 Nadav 建议的页面中的语法进行模糊处理:

https://support.cloudinary.com/hc/en-us/articles/203189031-How-to-retrieve-a-list-of-all-resources-sharing-the-same-tag-

这应该返回一个 JSON 吗?

【问题讨论】:

    标签: android-studio cloudinary


    【解决方案1】:

    以下功能允许您检索共享公共标签的 JSON 格式的资源列表:
    https://support.cloudinary.com/hc/en-us/articles/203189031-How-to-retrieve-a-list-of-all-resources-sharing-the-same-tag-

    请注意,图像删除将强制您使用服务器端代码(例如 JAVA),因为通过 Cloudinary 删除需要基于您的 API_SECRET 的签名。

    【讨论】:

    • 感谢您提供的链接,确实帮助我了解了如何实现这一目标,尽管在请求结果以及如何提取图像后我有点难以正确地做到这一点来自 JSON 的列表,也请您指导我在没有 api_secret 的情况下如何做到这一点,在 java/android studio 中如何做到这一点的链接中不清楚
    • @Nadav_Ofir 我在尝试应用 Admin API 文档中演示的方法时遇到了问题。正如您在上面看到的,我发布了我正在使用的代码和堆栈跟踪中的错误
    • @JanusJanus 查看访问 URL 时的响应。你有一个错误 - X-Cld-Error:Resources of type list are restricted in this account。您应该首先通过您的帐户Security Settings 页面允许“资源列表”。
    • 顺便说一句,它与 Admin-API 无关,也不需要您的API_SECRET - 这是一个纯粹的客户端功能。
    猜你喜欢
    • 1970-01-01
    • 2017-02-15
    • 2015-09-30
    • 2020-08-08
    • 2015-12-25
    • 2021-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多