Forum Discussion

Makhlouf's avatar
Makhlouf
Explorer | Level 3
6 years ago

Programmatically download a shared file using C++ Curl

Hi,

I developped an aplication in C++ that runs on Windows. I am trying to add a feauture in the program to download a shared file from my dropbox folder. I would like the downloading to go in background in similar way to windows API URLDownloadToFile(). The windows function downloads files from the web. But when I use the dropbox file link, the function downloads an html file instead of my file. I tried to use CURL library but got stuck with the access_token. I created an application access_token as described by Dropbox developper guide. When I use this access_token I receive authorization faliure error message. I wonder if the job I am trying to do is actually doable, and whether my approach is the right one. Where should I go or what should I do to get a shared file downloaded with my windows application. 

Thanks for your help

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    You can download a file from a shared link directly without using an access token, like you tried initially. Note that by default however, Dropbox shared links point to an HTML preview page, not the file data itself. You can modify the link to point to the file data though, as described here:

    https://help.dropbox.com/files-folders/share/force-download

    • Makhlouf's avatar
      Makhlouf
      Explorer | Level 3

      Thanks for your answer. I read this article and tried it but did not work. Here is my observations:

      1- If I leave the shared link as it is, curl will download an html file which when opened in a browser I get the below screen.

      2- If I chose to skip sign in, I can not download teh file.

      3- If I modified the shared link with dl=1 instead of dl=0, I receive nothing.

      4- Windows function URLDownloadToFile() download an html file using the original link also. However, it can not be open in the browser. It seems it has error message but I can not read html to find out the problem.Screenshot (42).png

      I am not quite sure what I am doing wrong. Please advise.

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        I'm not sure I follow. Can you share your code and whatever error/output you're getting when you try to download from a shared link with dl=1? Thanks in advance! 

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,940 PostsLatest Activity: 24 hours ago
350 Following

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 or Facebook.

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!