cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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: ECONNRESET while downloading shared file as a stream

ECONNRESET while downloading shared file as a stream

bambaba12
Explorer | Level 4

Hello, when I try to download a shared file using API , the socket closes at the 10th minute, and I receive an 'ECONNRESET' error. Without using the API, I was able to download for an hour. And after an hours it's closing the connection again. By the way, the file I'm downloading is over 100GB. Can you help me with this issue?

await this.httpService.axiosRef({
url: 'https://content.dropboxapi.com/2/sharing/get_shared_link_file',
method: 'POST',
headers: {
Authorization: `Bearer ${DROPBOX_API_TOKEN}`,
'Dropbox-API-Arg': JSON.stringify({ url: videoUrl }),
'Content-Type': 'application/octet-stream',
},
responseType: 'stream',
});
1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff

We've increased the /2/sharing/get_shared_link_file endpoint timeout. For downloads that will take a long time, please use Range requests to retrieve the entire file across multiple requests as described in my previous message.

View solution in original post

3 Replies 3

Greg-DB
Dropbox Staff

Thanks for the report! It looks like the /2/sharing/get_shared_link_file endpoint is configured with a 10 minute timeout. I'll ask the team to look into whether we can increase that.

 

As a workaround, whether you're using this /2/sharing/get_shared_link_file endpoint or are downloading from the shared link directly, you can use "Range" requests to download a portion of the file at a time.

 

So if you need to perform these downloads over periods of time longer than the relevant timeout, please use multiple requests lasting no longer than the timeout, to download a piece of the file per request, and then re-assemble the file.

 

For example, here's a sample of what it would look like in curl:

curl -v -X POST https://content.dropboxapi.com/2/sharing/get_shared_link_file \
  --header 'Authorization: Bearer ACCESS_TOKEN' \
  --header 'Dropbox-API-Arg: {"url":"SHARED_LINK"}' \
  --header 'Range: bytes=0-10'

That would download just the first 11 bytes of the file at the shared link. You can modify the byte range to download any piece of a file, such as to continue downloading the next portion of a file.

Greg-DB
Dropbox Staff

We've increased the /2/sharing/get_shared_link_file endpoint timeout. For downloads that will take a long time, please use Range requests to retrieve the entire file across multiple requests as described in my previous message.

bambaba12
Explorer | Level 4

Thank you. Yes, as you suggested, I started using range, and this has been more effective

Need more support?