Learn how to make the most out of the Dropbox Community here 💙!

Forum Discussion

lekn's avatar
lekn
Explorer | Level 3
5 years ago
Solved

Downloading zip files from Dropbox via API returns size zero

Hi,   I was trying to download zip files within a folder from my dropbox. For example, there are 7z files named 0.7z, 1.7z, ... 5.7z under folder name 'extra'. I could download the 7z files v...
  • Greg-DB's avatar
    Greg-DB
    5 years ago

    Apologies, I had the wrong link in that post. I just fixed it. It should be this post.

     

    Anyway, it looks like the issue is that you're running out of memory when downloading the file, since you're accessing the whole thing, and the file is very large.

     

    You can read off the download result in pieces like this:

    with open(new_file_path, 'wb') as new_file:
        for chunk in res.iter_content(chunk_size=4*1024*1024):  # or whatever chunk size you want
            new_file.write(chunk)

    (Note I also changed the file open mode to binary mode.)