We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
pankaj_agarwal
7 years agoExplorer | Level 3
How to use the public url to access files
I am trying to create an app in c# which will download files from a given url which looks like this https://wixlabs---dropbox-folder.appspot.com/index?instance=UexTyTTXTALjKbz1f1P3H5nZAFTiMsLw2wWcu_...
Greg-DB
Dropbox Community Moderator
7 years ago[Cross-linking for reference: https://stackoverflow.com/questions/54691106/need-help-coding-a-downloader-for-dropbox ]
The GetSharedLinkMetadataAsync method is meant for accessing the information about shared links from Dropbox itself, e.g., links like this:
https://www.dropbox.com/s/yvkdov5srlqalkd/Getting%20Started.pdf?dl=0
The link you shared is from "appspot.com", so it won't work with GetSharedLinkMetadataAsync.
If you're just trying to download a file from a publicly accessible link to the local filesystem, you don't need to use the Dropbox API; you can just use an HTTPS client.
If you want to save the linked file directly to a Dropbox account, you should instead use SaveUrlAsync.
- pankaj_agarwal7 years agoExplorer | Level 3
Can you give me some pointers on how to achieve this because with WebClient I am getting a HTML Page.
- Greg-DB7 years ago
Dropbox Community Moderator
What specifically are you trying to do, and what are you stuck on at this point?
If you're trying to downloading from appspot.com using WebClient, I can't offer help with that, as that's not related to Dropbox. (That said, what you describe does seem expected, since the link you shared is just to an HTML web page. It sounds like you probably would want to use the link to the file on that page instead.)
If you're trying to use SaveUrlAsync, or if you are trying to use GetSharedLinkMetadataAsync and switched to an actual Dropbox shared link, please shared your updated code and let me know what isn't working.
- pankaj_agarwal7 years agoExplorer | Level 3
The above link shows a folder with files in the browser. I am trying to download those files. I tried attaching the html file here but it is not working so I am pasting the code here:
<!DOCTYPE html> <html ng-app="myApp"> <head> <base href="/"> <title>Dropbox Folder</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="//static.parastorage.com/services/third-party/fonts/Helvetica/fontFace.css"> <link rel="stylesheet" href="styles/index.css"/> <script src="//static.parastorage.com/services/js-sdk/1.108.0/js/wix-private.min.js"></script> <script type="text/javascript"> var initialState = {"APP_ID":"14924864-56d5-b94b-060f-cd57bd16cc26","DEFAULT_LANGUAGE":"en","DISPLAY_MODE_FILES":"files","DISPLAY_MODE_FOLDER":"folder","LIST_FULL_WIDTH":1,"LIST_PARTIAL_WIDTH":0,"FOLDER_STYLE_OUTLINE":"outline","FOLDER_STYLE_SOLID":"solid","SIZE_SMALL":"small","SIZE_LARGE":"large","appName":"myApp","origin":"app_settings","widget_origin":"widget","appId":"14924864-56d5-b94b-060f-cd57bd16cc26","AUTH_URL":"https://www.dropbox.com/oauth2/authorize?client_id=rn9cfkc30p3l3po&response_type=token&state=testtoken&force_reapprove=false","APP_KEY":"rn9cfkc30p3l3po","REGISTER_URL":"https://www.dropbox.com/register","design":{"folder_row":{"color":"color-8","opacity":0.15},"bread_crumbs":{"color":"color-4","text":"Body-M","fontSize":12,"arrowColor":"color-4"},"number_items":{"color":"color-4","text":"Body-M","fontSize":12},"connected_cloud":{"color":"color-8","text":"Body-M"},"empty_folder_header":{"text":"Body-L","color":"color-5","fontSize":15,"fontWeight":"bold"},"empty_folder_text":{"text":"Body-M","color":"color-4","fontSize":14},"empty_folder_image":{"color":"color-8"},"icon_color":{"name":"iconColor","value":"color-8","opacity":"0.8"},"folder_icon":{"textFont":{"name":"folderIconFont","value":"Body-M","theme":"font_8"},"textColor":{"name":"folderIconColor","value":"color-8"}},"list":{"title":{"textFont":{"name":"ListTitleFont","value":"Body-L","theme":"font_7","startWithSize":20,"maxSize":42},"textColor":{"name":"ListTitleColor","value":"color-5"}},"files_names":{"textFont":{"name":"ListFilesNamesFont","value":"Body-M","theme":"font_8","maxSize":22},"textColor":{"name":"ListFilesNamesColor","value":"color-4"}},"background":{"value":"color-1","name":"listBackgroundColor","opacity":"1"},"border":{"value":"color-5","name":"listBorderColor","opacity":"0.2"},"icons":{"name":"iconsListColor","value":"color-8"}}},"data":{"settings":{"design":{"folder":{"icon_size":"small","style":"outline"},"list":{"show_numbers_of_items":1,"show_preview":1}},"lang":"en","email":{"text":"","show":1},"layout":{"type":"files"},"account":{"folderPath":"[{\"name\":\"Dropbox\",\"path_lower\":\"/\"}]","folder":"OmniScreen","email":"omnicoomniscreen@gmail.com","name":"OmniScreen Omnico","accessToken":"","fullPath":"/omniscreen","connected":1},"title":{"show":1,"text":"OmniScreen"}}}}; initialState.locationParams = document.location.search; </script> <style wix-style type="text/css" ng-non-bindable=""> .folderRow::before { background-color: {{color-8}}; opacity: 0.15; } .file-arrow #z-Stroke-2 { stroke: {{color-4}}; } .folder-path-text{ font-size: 12px !important; color: {{color-4}}; {{Body-M}}; } .items-row { font-size: 12px !important; color: {{color-4}}; {{Body-M}}; } .title { {{Body-L}}; font-size: 20px; {{style.ListTitleFont}}; color: {{style.ListTitleColor color-5}}; } .closeMe .closeMe-fill { fill: {{style.ListTitleColor color-5}}; } .folderName { {{ style.ListFilesNamesFont Body-M}} color: {{style.ListFilesNamesColor color-4}} } .extention , .fileNameNoExtention{ {{ style.ListFilesNamesFont Body-M}} color: {{style.ListFilesNamesColor color-4}} } .items { font-size: 12px !important; color: {{color-4}}; {{Body-M}}; } .ispopup { background-color: {{style.listBackgroundColor color-1}}; } .defaultBackground{ background-color: {{style.listBackgroundColor color-1}}; border : 1px solid rgba(0,0,0,0.2) ; border-color: {{style.listBorderColor}} !important; } .previewBorder{ background-color: {{style.listBackgroundColor color-1}}; } .webui-popover,.previewBorder,.full-screen-connected { border-color: {{color-5}} ; border-color: {{style.listBorderColor}} !important; } .full-screen-connected { background-color: {{color-1}}; color: {{color-5}}; } .divider , .lastDivider { background-color: {{color-5}} ; background-color: {{style.listBorderColor}}; } .mCSB_dragger_bar.inited{ background-color: {{color-5}} !important; background-color: {{style.listBorderColor}} !important; } #mCSB_2_scrollbar_vertical{ } .webui-arrow { border-top-color: {{style.listBorderColor color-5}} !important; } .arrowIcon .fill-svg, .mobileArrow .fill-svg , .home-icon path{ fill-rule: evenodd; fill : {{style.iconsListColor color-8}} !important; } .downloadFolderIcon .stroke-svg , .downloadFolderIcon path{ stroke : {{style.iconsListColor color-8}}; } .viewFileIcon .symbol-showComp path{ fill : {{style.iconsListColor color-8}}; } .closeMe .closeMe-fill { fill : {{style.iconsListColor color-8}}; } .folder-path-text:not(.selected-folder){ color : {{style.iconsListColor color-8}}; } .fileIcon .fill-svg , .folderIcon .fill-svg{ fill: {{style.iconsListColor color-8}}; } .fileIcon .stroke-svg , .folderIcon .stroke-svg { stroke: {{style.iconsListColor color-8}}; } .folderLayoutIconFill .fill-svg , .folderLayoutIconNotFill .fill-svg { fill: {{style.iconColor color-8}}; } .folderLayoutIconFill .stroke-svg, .folderLayoutIconNotFill .stroke-svg{ stroke: {{style.iconColor color-8}}; } .folderTitle{ {{style.folderIconFont Body-M}}; color : {{style.folderIconColor color-8}}; line-height: 1.4em; } .connected-cloud path { stroke: {{color-8}}; } .connected-cloud path.fill-connected { fill: {{color-8}}; } .connected-cloud--text { {{Body-M}}; } .empty-folder--header { {{Body-L}}; color: {{color-5}}; font-size: 15px; font-weight: bold; } .empty-folder--text { {{Body-M}}; color: {{color-4}}; font-size: 14px; } .empty-folder--image svg g{ fill: {{color-8}} !important; } </style> </head> <body role="application"> <div ng-view class="my-app" tabindex="-1" role="main"></div> <script src="scripts/bower-index.js"></script> <script src="scripts/scripts-index.js"></script> </body> </html>There is a big JSON object which might be relevant as it shows links to dropbox but I am not sure how to make use of that.
Basically being able to enumerate files and folders is what I am trying to achieve in my app. This is what I tried:
private static void Fetch(string url) { using (var webClient = new WebClient()) { var uri = new Uri(url); //webClient.OpenReadCompleted += WebClient_OpenReadCompleted; //webClient.OpenReadAsync(uri); webClient.DownloadFileAsync(uri, @"D:\xyz.dat"); } } private static void WebClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { using(StreamReader reader=new StreamReader(e.Result)) { Console.WriteLine(reader.ReadToEnd()); } }
About Discuss Dropbox Developer & API
Make connections with other developers
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!