We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

toki4004's avatar
toki4004
Helpful | Level 5
2 years ago
Solved

Download ANY file in folder

To download a file I need a full path. What if I don't know the name of the file? How would I list that path then to grab any txt file?

 "path": "/Homework/math/Prime_Numbers.txt"

 

  • toki4004, You can search for such files using /2/files/search_v2/continue_v2. Just restrict the search to particular extension and look in filename only with the same string as the extension. In the resulting list you will see all such files with their paths, ids, and revisions (you can use anything of them to download particular file or set of files).

    Hope this helps.

7 Replies

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    2 years ago

    toki4004, You can search for such files using /2/files/search_v2/continue_v2. Just restrict the search to particular extension and look in filename only with the same string as the extension. In the resulting list you will see all such files with their paths, ids, and revisions (you can use anything of them to download particular file or set of files).

    Hope this helps.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    2 years ago

    toki4004 In addition to the search functionality that Здравко mentioned, you can list all of the contents of any particular folder using /2/files/list_folder[/continue].

     

    For example, if you know a parent folder path, you would set the "path" like "/Homework/math". Or, to list the root, you would supply the "path" as the empty string "".

  • toki4004's avatar
    toki4004
    Helpful | Level 5
    2 years ago

    Greg-DB 

    I can list contents of a folder with an open path but I can't download a file with just the folder name in the path, correct? If I try that, I get errors... 

    I am trying to stay away form list -> then download, because I'd have to make 2 trips to DB - performance-wise that would not be ideal. 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    2 years ago

    toki4004 To download a specific file, you can use /2/files/download and specify the full path of the file you want, including any parent folder names, like "/Homework/math/Prime_Numbers.txt".

     

    To download a whole folder, you can use /2/files/download_zip and specify the name of the folder, like "/Homework/math" or "/Homework".

  • toki4004's avatar
    toki4004
    Helpful | Level 5
    2 years ago

    If I use "search" - what would I put for "query"? I don't know the file name - I only know the extension so I'll put that under options =>file_extensions

    But query is required...

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    2 years ago

    Здравко wrote:

    ... You can search for such files using /2/files/search_v2/continue_v2. Just restrict the search to particular extension and look in filename only with the same string as the extension. ...



    toki4004 wrote:

    If I use "search" - what would I put for "query"? I don't know the file name - I only know the extension so I'll put that under options =>file_extensions

    But query is required...


    Hm..🤔 What's the name of that parameter where you denote what you're looking for (either from file content or its name)? In the particular case we need to direct Dropbox to search in filename only... Ohh...yes. 😀 That was the "query"! 🤫

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 8 hours ago
410 Following

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 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!