大佬教程收集整理的这篇文章主要介绍了android – Dropbox共享文件URL,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我仍然希望将文件管理到某些功能,例如放置文件并从DropBox获取文件.现在的问题是当我把一些文件放在DropBox的公用文件夹中,我需要一个URL来分享给应用程序中的联系人.但是在API中,我找不到任何返回要共享的文件的网址的函数(就像在DropBox的Deskotop界面中,用户可以获得一个共享URL来发送给朋友).
有人可以帮我弄清楚如何与应用程序中的联系人共享文件?
如果您使用Android DropBox Core 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); } }
更新:2014/07/20 Dheeraj Bhaskar
与上述功能一起使用以下帮助函数.
由于DropBox开始发送缩短的链接,所以要获得正确的链接有一点问题.
现在,我使用这种方法:
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; }
更新2014/07/25:更改收件箱共享网址
关于预期的URL类型的单挑
从DropBox小组:
以上是大佬教程为你收集整理的android – Dropbox共享文件URL全部内容,希望文章能够帮你解决android – Dropbox共享文件URL所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。