根据DropBox对此处所述的更改:https://www.dropbox.com/help/16/en 将不再有公共文件夹,而是可以通过共享链接访问文件。
如果你使用Android的DropBox核心API,然后共享链路可以检索这样:
// Get the metadata for a directory
Entry dirent = mApi.metadata(mPath, 1000, null, true, null);
for (Entry ent : dirent.contents) {
String shareAddress = null;
if (!ent.isDir) {
DropboxLink shareLink = mApi.share(ent.path);
shareAddress = getShareURL(shareLink.url).replaceFirst("https://www", "https://dl");
Log.d(TAG, "dropbox share link " + shareAddress);
}
}
UPDATE:由Dheeraj巴斯卡尔 使用下面的辅助函数非常久远上述功能2014年7月20日。 因为DropBox开始发送缩短的链接,所以得到正确的链接会有点问题。 现在,我正在使用这种方法:
我们只需加载URL,按照重定向并获取新的URL。
String getShareURL(String strURL) {
URLConnection conn = null;
String redirectedUrl = null;
try {
URL inputURL = new URL(strURL);
conn = inputURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
System.out.println("Redirected URL: " + conn.getURL());
redirectedUrl = conn.getURL().toString();
is.close();
} catch (MalformedURLException e) {
Log.d(TAG, "Please input a valid URL");
} catch (IOException ioe) {
Log.d(TAG, "Can not connect to the URL");
}
return redirectedUrl;
}
注:所有这一切都应该在的AsyncTask或线程来完成课程。这将产生准备下载正确的链接
更新2014/07/25:变化的dropbox共享URL,
的那种URL的抬头期待
从Dropbox的团队:
我们想给你一个关于即将到来的修改Dropbox共享链接的URL 结构的提示。虽然不是API的一部分,但 更改可能会影响操纵从 /shares端点返回的URL或由Chooser 插入返回的“预览”链接类型的应用程序。
返回的链接现在会附加一个?dl = 0。
例如,而不是 https://www.dropbox.com/s/99eqbiuiepa8y7n/Fluffbeast.docx,您会收到 网址 这样的链接 https://www.dropbox.com/s/99eqbiuiepa8y7n/Fluffbeast.docx?dl=0。
我发现了一些文档:https://www.dropbox.com/developers/docs 你是指别的东西吗? – KPthunder 2011-04-23 17:16:08
@KPthunder ..谢谢你的回复...我已经看到这个文档已经没有方法提及共享那是我的问题。 谢谢 – 2011-04-27 09:05:21