<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error downloading files from dropbox API in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259520#M15097</link>
    <description>&lt;P&gt;You do need to use the full path when specifying the file you want to download. Using&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.dropbox.Dropbox.files_list_folder" target="_self" rel="nofollow noopener noreferrer"&gt;files_list_folder&lt;/A&gt; and&amp;nbsp;&lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.dropbox.Dropbox.files_list_folder_continue" target="_blank" rel="nofollow noopener noreferrer"&gt;files_list_folder_continue&lt;/A&gt;&amp;nbsp;will give you every entry, and you can get the full path from the returned (File)&lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.files.Metadata.path_lower" target="_self"&gt;Metadata.path_lower&lt;/A&gt;. (I.e., use `entry.path_lower` instead of `'/'+entry.name`.)&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jan 2018 21:01:15 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2018-01-08T21:01:15Z</dc:date>
    <item>
      <title>Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259377#M15075</link>
      <description>&lt;P&gt;I am trying to download files from dropbox but keep hitting the ValidationError.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;for dfiles in flist:
        dbx.files_download_to_file('/Users/fela/Downloads/dropbox', dfiles, rev=None)&lt;/PRE&gt;
&lt;P&gt;Here is the error:&lt;/P&gt;
&lt;PRE&gt;ValidationError at /dropbox_auth_finish
'2005-02-15 00.39.15-2.tif' did not match pattern '(/(.|[\r\n])*|id:.*)|(rev:[0-9a-f]{9,})|(ns:[0-9]+(/.*)?)'
Request Method:	GET
Request URL:	https://localhost:8000/dropbox_auth_finish?state=fNWCqBEYwxETbqJU-N5zlA%3D%3D&amp;amp;code=wPfEvSKsCIEAAAAAAAAZdQWDsobxTQufArgHJU7is
Django Version:	1.11.3
Exception Type:	ValidationError
Exception Value:	
'2005-02-15 00.39.15-2.tif' did not match pattern '(/(.|[\r\n])*|id:.*)|(rev:[0-9a-f]{9,})|(ns:[0-9]+(/.*)?)'
Exception Location:	/Users/fela/miniconda3/envs/clauks/lib/python3.6/site-packages/dropbox/stone_validators.py in validate, line 317
Python Executable:	/Users/fela/miniconda3/envs/clauks/bin/python
Python Version:	3.6.2&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:16:16 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259377#M15075</guid>
      <dc:creator>pyraxic</dc:creator>
      <dc:date>2019-05-29T09:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259386#M15077</link>
      <description>&lt;P&gt;Seems like I was missing a leading "/" from my command but now it gives another error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;for dfiles in flist:
        dbx.files_download_to_file('/Users/fela/Downloads/dropbox/'+dfiles, '/'+dfiles, rev=None)&lt;/PRE&gt;
&lt;P&gt;Error:&lt;/P&gt;
&lt;PRE&gt;ApiError at /dropbox_auth_finish
ApiError('41b9e1718f4f92d51231197741ac31d5', DownloadError('path', LookupError('not_found', None)))
Request Method:	GET
Request URL:	https://localhost:8000/dropbox_auth_finish?state=NSz1ObeJgWL234R2kIXBMw%3D%3D&amp;amp;code=wPfEvSKsCIEAAAAAAAAZi9WtSCRKLq18aMUUfGQJY
Django Version:	1.11.3
Exception Type:	ApiError
Exception Value:	
ApiError('41b9e1718f4f92d51231197741ac31d5', DownloadError('path', LookupError('not_found', None)))
Exception Location:	/Users/fela/miniconda3/envs/clauks/lib/python3.6/site-packages/dropbox/dropbox.py in request, line 256
Python Executable:	/Users/fela/miniconda3/envs/clauks/bin/python
Python Version:	3.6.2&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jan 2018 03:52:57 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259386#M15077</guid>
      <dc:creator>pyraxic</dc:creator>
      <dc:date>2018-01-08T03:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259394#M15079</link>
      <description>&lt;P&gt;I figured it out. It seems that I need to enter the remote path name. For example, if I have a folder named "Camera", it should use /Camera/filename. But how do I get the list of folder name and files under that folder name (if I have multiple folders)? I could use&amp;nbsp;&lt;EM&gt;files_list_folder&amp;nbsp;&lt;/EM&gt;which gives me the list of files but how can I get the&amp;nbsp;hierarchy (folder structure)?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 06:41:20 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259394#M15079</guid>
      <dc:creator>pyraxic</dc:creator>
      <dc:date>2018-01-08T06:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259485#M15086</link>
      <description>&lt;P&gt;That's correct, the `path` parameter value for &lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#module-dropbox.files" target="_self"&gt;files_download_to_file&lt;/A&gt;&amp;nbsp;should be the full remote (Dropbox) path of the file you want to download.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using &lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.dropbox.Dropbox.files_list_folder" target="_self"&gt;files_list_folder&lt;/A&gt;&amp;nbsp;is the right way to list files and folders under any particular path. (Use the empty string "" as the path for root if that's what you're looking for.)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to list everything, included nested items, set recursive=true. Either way, be sure to check the resulting &lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.files.ListFolderResult.has_more" target="_self"&gt;ListFolderResult.has_more&lt;/A&gt;&amp;nbsp;to see if you need to call back to&amp;nbsp;&lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.dropbox.Dropbox.files_list_folder_continue" target="_blank"&gt;files_list_folder_continue&lt;/A&gt;&amp;nbsp;to get more results.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 18:03:27 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259485#M15086</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-01-08T18:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259519#M15096</link>
      <description>&lt;P&gt;Here is my code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dbx = dropbox.Dropbox(oauth_result.access_token)
    result = dbx.files_list_folder("", recursive=True)
    flist = []

    def process_entries(entries):
        for entry in entries:
            if isinstance(entry, dropbox.files.FileMetadata):
                flist.append(entry.name)
                dbx.files_download_to_file('/Users/fela/Downloads/dropbox/'+entry.name, '/'+entry.name)&lt;/PRE&gt;
&lt;P&gt;It gives me an error:&lt;/P&gt;
&lt;PRE&gt;ApiError('9102ee3554ff1ef69453c208accc6568', DownloadError('path', LookupError('not_found', None)))&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Unless I use "/Camera". As you can see that I am using "" with recursive=True to go through the entire dropbox and list files. I am not able to download it unless I specify the folder name. How can I get the folder structure and files under them so I can download files from the root folder and all the subfolders under them?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 20:55:26 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259519#M15096</guid>
      <dc:creator>pyraxic</dc:creator>
      <dc:date>2018-01-08T20:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259520#M15097</link>
      <description>&lt;P&gt;You do need to use the full path when specifying the file you want to download. Using&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.dropbox.Dropbox.files_list_folder" target="_self" rel="nofollow noopener noreferrer"&gt;files_list_folder&lt;/A&gt; and&amp;nbsp;&lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.dropbox.Dropbox.files_list_folder_continue" target="_blank" rel="nofollow noopener noreferrer"&gt;files_list_folder_continue&lt;/A&gt;&amp;nbsp;will give you every entry, and you can get the full path from the returned (File)&lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.files.Metadata.path_lower" target="_self"&gt;Metadata.path_lower&lt;/A&gt;. (I.e., use `entry.path_lower` instead of `'/'+entry.name`.)&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 21:01:15 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259520#M15097</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-01-08T21:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259522#M15098</link>
      <description>&lt;P&gt;Awesome! That works. Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 21:12:48 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/259522#M15098</guid>
      <dc:creator>pyraxic</dc:creator>
      <dc:date>2018-01-08T21:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/263006#M15358</link>
      <description>&lt;P&gt;this example (Download file), do you have in github or similar plataform?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 00:20:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/263006#M15358</guid>
      <dc:creator>rhernandez8305</dc:creator>
      <dc:date>2018-01-31T00:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/263019#M15359</link>
      <description>&lt;P&gt;I don't have an example but if you follow the documentation from &lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/" target="_self"&gt;dropbox&lt;/A&gt;, it should walk you through it.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 05:16:12 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/263019#M15359</guid>
      <dc:creator>pyraxic</dc:creator>
      <dc:date>2018-01-31T05:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/263077#M15362</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/606403"&gt;@rhernandez8305&lt;/a&gt;&amp;nbsp;We do have &lt;A href="https://github.com/dropbox/dropbox-sdk-python/tree/master/example" target="_self"&gt;some samples included with the Python SDK on GitHub&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, here are some download calls:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-python/blob/master/example/updown.py#L157&amp;nbsp;" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-python/blob/master/example/updown.py#L157&amp;nbsp;&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-python/blob/master/example/back-up-and-restore/backup-and-restore-example.py#L55&amp;nbsp;" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-python/blob/master/example/back-up-and-restore/backup-and-restore-example.py#L55&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 15:29:33 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/263077#M15362</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-01-31T15:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Error downloading files from dropbox API</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/314681#M18683</link>
      <description>&lt;P&gt;Another solution that might better fit your needs is to use the http api instead &lt;A href="https://www.dropbox.com/developers/documentation/http/overview" target="_blank"&gt;https://www.dropbox.com/developers/documentation/http/overview&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Specifically looking at the "files/download" endpoint. &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-download" target="_blank"&gt;https://www.dropbox.com/developers/documentation/http/documentation#files-download&lt;/A&gt;&lt;/P&gt;&lt;P&gt;With the python dropbox sdk you download each file synchronously. In order to get some more efficency you can use some of the asynchronous functionality in python 3.7 (and some additional libraries) to try and download your files together.&lt;/P&gt;&lt;P&gt;Here is some example code that will save a list of files to your "/tmp" directory&lt;/P&gt;&lt;PRE&gt;import aiohttp
import aiofiles
import asyncio
import json
from tqdm import tqdm_notebook as tqdm

DROPBOX_URL='https://content.dropboxapi.com/2/files/download'

async def dropbox_async_download(session, path, prefix_path="/tmp"):
    
    ## Create headers to talk to dropbox api
    ## see https://www.dropbox.com/developers/documentation/http/documentation#files-download
    headers = {
        "Authorization": "Bearer %s"%os.environ["DROPBOX_ACCESS_TOKEN"],
        "Dropbox-API-Arg": json.dumps({"path": path})
    }
    
    ## Create async post request
    ## Open file asynchronously
    ## write chunks from server async to file
    i=0
    with tqdm(total=1000) as pbar:
        async with session.post(DROPBOX_URL, headers=headers) as response,\
                   aiofiles.open(prefix_path+path, "w")       as f:
                async for chunk, _ in response.content.iter_chunks():
                    await f.write(chunk.decode('utf-8'))
                    pbar.set_postfix(file=path)
                    pbar.update(1)
    print ("Done!", path)

async def dropbox_download_files(files):
    async with aiohttp.ClientSession() as session:
        coroutines = list(
            map(lambda f:dropbox_async_download(session,f),files)
        )
        return await asyncio.gather(*coroutines)&lt;BR /&gt;&lt;BR /&gt;files = ["a.txt", "b.txt", "c.txt"]&lt;BR /&gt;loop = asyncio.get_event_loop()&lt;BR /&gt;loop.run_until_complete(dropbox_download_files(files)&lt;/PRE&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 16:03:46 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-downloading-files-from-dropbox-API/m-p/314681#M18683</guid>
      <dc:creator>acomerford</dc:creator>
      <dc:date>2018-11-30T16:03:46Z</dc:date>
    </item>
  </channel>
</rss>

