【发布时间】: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 建议的页面中的语法进行模糊处理:
这应该返回一个 JSON 吗?
【问题讨论】: