cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Large File Download

Large File Download

gagsbh
Explorer | Level 4
Go to solution

Hello,

 

I used Dropbox SDK for .NET to download a large file of size 1.3 GB but the program hung.

 

using (var response = await dbx.Files.DownloadAsync(path + "/" + file))
{
    byte[] buffer = await response.GetContentAsByteArrayAsync();
}

 

I then used Dropbox REST API - "https://content.dropboxapi.com/2/files/download"
with Authorization and Dropbox-API-Arg (with path as argument) as headers.
For smaller files the Rest Api worked, but for the 1.3 GB file download, the program threw "Out of Memory Exception".

 

How do I perform a download of such a larger file with size > 1GB.

 

Thanks,
Gagan

 
 
1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
You appear to be trying to read the entirety of the contents into memory, which is likely to fail for large files like this.

You'll probably want to use GetContentAsStreamAsync in the SDK (instead of GetContentAsByteArrayAsync), so you can access the contents via a stream, instead of reading it all into memory:

https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Stone_IDownloadResponse_1_GetContent...

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution
You appear to be trying to read the entirety of the contents into memory, which is likely to fail for large files like this.

You'll probably want to use GetContentAsStreamAsync in the SDK (instead of GetContentAsByteArrayAsync), so you can access the contents via a stream, instead of reading it all into memory:

https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Stone_IDownloadResponse_1_GetContent...

gagsbh
Explorer | Level 4
Go to solution

Thanks! It worked.

 
Need more support?