I'm trying to download a large (80Gb) file from the Dropbox servers.
After *exactly* one hour, I get an exception indicating that the Dropbox servers have dropped the connection (System.IO.IOException: The response ended prematurely. in .NET)
I'm trying to download a large (80Gb) file from the Dropbox servers.
After *exactly* one hour, I get an exception indicating that the Dropbox servers have dropped the connection (System.IO.IOException: The response ended prematurely. in .NET)
\n
\n
If these are failing after an hour, that would be due to the server timeout. There isn't an option to delay or prevent that.
\n
\n
Content-download style endpoints, such as /2/files/download, support \"range requests\" though. I recommend using range requests to continue downloading the rest of the data if a connection fails, and repeat as needed for up to one hour per connection.
\n
\n
Here's a basic example showing how to do that:
\n
HttpClient client = new HttpClient();\n\nHttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, \"https://content.dropboxapi.com/2/files/download\");\nrequest.Headers.Add(\"Authorization\", \"Bearer \" + accessToken);\nrequest.Headers.Add(\"Dropbox-API-Arg\", \"{\\\"path\\\":\\\"/test.txt\\\"}\"); // in real code, use a JSON library to build this\nrequest.Headers.Add(\"Range\", \"bytes=5-\"); // this requests the rest of the file after the first 5 bytes\n\nHttpResponseMessage response = await client.SendAsync(request);\nStream stream = response.Content.ReadAsStream(); // read from stream as desired
\n
For instance, in this example, this would be helpful if the app previously only downloaded the first 5 bytes of the file, and needs the rest. In your actual use, you would programmatically set the byte range as needed based on what you successfully downloaded so far of course.
\n
\n
","body@stripHtml({\"removeProcessingText\":false,\"removeSpoilerMarkup\":false,\"removeTocMarkup\":false,\"truncateLength\":200})@stringLength":"208","kudosSumWeight":0,"postTime":"2023-03-31T10:27:22.811-07:00","lastPublishTime":"2023-03-31T10:27:22.811-07:00","solution":true,"metrics":{"__typename":"MessageMetrics","views":4129},"visibilityScope":"PUBLIC","placeholder":false,"originalMessageForPlaceholder":null,"isEscalated":null,"entityType":"FORUM_REPLY","eventPath":"category:101000041/category:101007/category:English/community:mxpez29397board:101000014/message:673260/message:673276","replies":{"__typename":"MessageConnection","pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null},"edges":[{"__typename":"MessageEdge","cursor":"MjUuMXwyLjF8aXwzfDUyOjF8aW50LDY3MzI4Nyw2NzMyODc","node":{"__ref":"ForumReplyMessage:message:673287"}}]},"body@stripHtml({\"removeProcessingText\":true,\"removeSpoilerMarkup\":true,\"removeTocMarkup\":true,\"truncateLength\":200})@stringLength":"208","images":{"__typename":"AssociatedImageConnection","edges":[],"totalCount":0,"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}},"attachments":{"__typename":"AttachmentConnection","pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null},"edges":[]},"videos":{"__typename":"VideoConnection","edges":[],"totalCount":0,"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}},"customFields":[]},"ModerationData:moderation_data:673287":{"__typename":"ModerationData","id":"moderation_data:673287","status":"APPROVED","rejectReason":null,"isReportedAbuse":false,"rejectUser":null,"rejectTime":null,"rejectActorType":null},"ForumReplyMessage:message:673287":{"__typename":"ForumReplyMessage","author":{"__ref":"User:user:1341719"},"id":"message:673287","revisionNum":1,"uid":673287,"depth":2,"hasGivenKudo":false,"subscribed":false,"board":{"__ref":"Forum:board:101000014"},"parent":{"__ref":"AcceptedSolutionMessage:message:673276"},"conversation":{"__ref":"Conversation:conversation:673260"},"subject":"Re: \"The response ended prematurely\" after one hour of a file download","moderationData":{"__ref":"ModerationData:moderation_data:673287"},"body":"Thank you! That works a treat.
","body@stripHtml({\"removeProcessingText\":false,\"removeSpoilerMarkup\":false,\"removeTocMarkup\":false,\"truncateLength\":200})@stringLength":"32","kudosSumWeight":0,"repliesCount":0,"postTime":"2023-03-31T11:49:54.199-07:00","lastPublishTime":"2023-03-31T11:49:54.199-07:00","metrics":{"__typename":"MessageMetrics","views":4006},"visibilityScope":"PUBLIC","placeholder":false,"originalMessageForPlaceholder":null,"isEscalated":null,"solution":false,"entityType":"FORUM_REPLY","eventPath":"category:101000041/category:101007/category:English/community:mxpez29397board:101000014/message:673260/message:673287","replies":{"__typename":"MessageConnection","pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null},"edges":[]},"customFields":[],"attachments":{"__typename":"AttachmentConnection","edges":[],"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}}},"QueryVariables:MessageSolutions":{"__typename":"QueryVariables","id":"MessageSolutions","value":{"first":10,"constraints":{"topicId":{"eq":"message:673260"},"solution":{"eq":true}},"sorts":{"postTime":{"direction":"ASC"}},"useAvatar":true,"useAuthorLogin":true,"useAuthorRank":false,"useBody":true,"useKudosCount":false,"useTimeToRead":false,"useMedia":true,"useRepliesCount":false,"useSearchSnippet":false,"useAcceptedSolutionButton":true,"useSolvedBadge":false,"useAttachments":true,"useTags":false,"useUserHoverCard":false,"useNodeHoverCard":false,"usePreviewSubjectModal":false,"useMessageStatus":false}},"CachedAsset:text:en_US-components/community/NavbarDropdownToggle-1740650493051":{"__typename":"CachedAsset","id":"text:en_US-components/community/NavbarDropdownToggle-1740650493051","value":{"ariaLabelClosed":"Press the down arrow to open the menu"},"localOverride":false},"CachedAsset:text:en_US-components/customComponent/CustomComponent-1740650493051":{"__typename":"CachedAsset","id":"text:en_US-components/customComponent/CustomComponent-1740650493051","value":{"errorMessage":"Error rendering component id: {customComponentId}","bannerTitle":"Video provider requires cookies to play the video. Accept to continue or {url} it directly on the provider's site.","buttonTitle":"Accept","urlText":"watch"},"localOverride":false},"CachedAsset:text:en_US-components/messages/EscalatedMessageBanner-1740650493051":{"__typename":"CachedAsset","id":"text:en_US-components/messages/EscalatedMessageBanner-1740650493051","value":{"escalationMessage":"Escalated to Salesforce by