<?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: .NET Downloading large file GetContentAsStreamAsync in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214599#M10996</link>
    <description>&lt;P&gt;It's failing after some time... I am downloading a large file, in the case of the test it's a file that's 245 MB.&lt;/P&gt;
&lt;P&gt;Downloading this file directly from dropbox took about 6 minutes.&lt;/P&gt;
&lt;P&gt;Is there a way to set the time out &amp;nbsp;for a longer period?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2017 18:14:54 GMT</pubDate>
    <dc:creator>JohnnyNPC</dc:creator>
    <dc:date>2017-04-04T18:14:54Z</dc:date>
    <item>
      <title>.NET Downloading large file GetContentAsStreamAsync</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214321#M10974</link>
      <description>&lt;P&gt;I want to use the Dropbox. Api for .NET to allow my users to download files I have stores in Dropbox from my site.&lt;/P&gt;&lt;P&gt;The size of the files ranges from small (a few Mb) to Big (a couple of Hundred Mb)&lt;/P&gt;&lt;P&gt;This is the code I have:&lt;/P&gt;&lt;PRE&gt;public async void DownloadWithTracking(string argFilePath)
    {
        var aFileName = Path.GetFileName(argFilePath);
        
        using (var aDropboxClient = new DropboxClient(anAccessToken))
        {
            var aResponse = await aDropboxClient.Files.DownloadAsync(argFilePath);

            ulong aFileSize = aResponse.Response.Size;
            const int aBufferSize = 4 * 1024 * 1024;

            var aBuffer = new byte[aBufferSize];

            using (var aDropboxContentStream = await aResponse.GetContentAsStreamAsync())
            {
                Response.BufferOutput = false;
                Response.AddHeader("content-disposition", "attachment;filename=" + aFileName);
                Response.AddHeader("Content-Length", aFileSize.ToString());
                int aLengthOfBytesRead = aDropboxContentStream.Read(aBuffer, 0, aBufferSize);
                while (aLengthOfBytesRead &amp;gt; 0)
                {
                    Response.OutputStream.Write(aBuffer, 0, aLengthOfBytesRead);
                    aLengthOfBytesRead = aDropboxContentStream.Read(aBuffer, 0, aBufferSize);
                }
            }
        }
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the files are small this code works perfectly but for the bigger files I get an error with this stackTrace:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;System.IO.IOException was unhandled by user code
  HResult=-2146232800
  Message=The read operation failed, see inner exception.
  Source=System.Net.Http
  StackTrace:
       at System.Net.Http.HttpClientHandler.WebExceptionWrapperStream.Read(Byte[] buffer, Int32 offset, Int32 count)
       at System.Net.Http.DelegatingStream.Read(Byte[] buffer, Int32 offset, Int32 count)
       at test_DropboxTest.&amp;lt;DownloadWithTracking&amp;gt;d__0.MoveNext() in d:\Dropbox\NPC Website\website\test\DropboxTest.aspx.cs:line 41
  InnerException: System.Net.WebException
       HResult=-2146233079
       Message=The request was aborted: The request was canceled.
       Source=System
       StackTrace:
            at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
            at System.Net.Http.HttpClientHandler.WebExceptionWrapperStream.Read(Byte[] buffer, Int32 offset, Int32 count)
       InnerException: &lt;/PRE&gt;&lt;P&gt;This happens after a few 10's of MB (from 20-50 Mb)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:24:06 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214321#M10974</guid>
      <dc:creator>JohnnyNPC</dc:creator>
      <dc:date>2019-05-29T09:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: .NET Downloading large file GetContentAsStreamAsync</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214590#M10994</link>
      <description>&lt;P&gt;[Cross-linking for reference:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/43208069/dropbox-net-downloading-large-files-using-getcontentasstreamasync" target="_blank"&gt;https://stackoverflow.com/questions/43208069/dropbox-net-downloading-large-files-using-getcontentasstreamasync&lt;/A&gt; ]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't seem to reproduce this issue. Is it failing after a certain amount of time? If so, it may be timing out, which would vary by network connection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, are you trying to download multiple files at once? If so, how many?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 17:44:46 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214590#M10994</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-04-04T17:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: .NET Downloading large file GetContentAsStreamAsync</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214599#M10996</link>
      <description>&lt;P&gt;It's failing after some time... I am downloading a large file, in the case of the test it's a file that's 245 MB.&lt;/P&gt;
&lt;P&gt;Downloading this file directly from dropbox took about 6 minutes.&lt;/P&gt;
&lt;P&gt;Is there a way to set the time out &amp;nbsp;for a longer period?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 18:14:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214599#M10996</guid>
      <dc:creator>JohnnyNPC</dc:creator>
      <dc:date>2017-04-04T18:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: .NET Downloading large file GetContentAsStreamAsync</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214602#M10997</link>
      <description>How long does it take to fail when you're trying to download via the API? If it is a timeout issue, there may be a way to configure that, but we'll have to look into it.&lt;BR /&gt;&lt;BR /&gt;Also, are you trying to download multiple files at once?</description>
      <pubDate>Tue, 04 Apr 2017 18:31:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214602#M10997</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-04-04T18:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: .NET Downloading large file GetContentAsStreamAsync</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214604#M10998</link>
      <description>It takes one and a half to two minutes, give or take.&lt;BR /&gt;In the internal tests I'm running now I'm only trying to download one file at the time.</description>
      <pubDate>Tue, 04 Apr 2017 18:36:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214604#M10998</guid>
      <dc:creator>JohnnyNPC</dc:creator>
      <dc:date>2017-04-04T18:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: .NET Downloading large file GetContentAsStreamAsync</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214606#M10999</link>
      <description>Thanks! In that case, you can specify a longer timeout as shown here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-dotnet/blob/master/Examples/SimpleTest/Program.cs#L49" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-dotnet/blob/master/Examples/SimpleTest/Program.cs#L49&lt;/A&gt;</description>
      <pubDate>Tue, 04 Apr 2017 18:50:40 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/NET-Downloading-large-file-GetContentAsStreamAsync/m-p/214606#M10999</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-04-04T18:50:40Z</dc:date>
    </item>
  </channel>
</rss>

