<?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: Download any file as a Stream using C# SDK in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Download-any-file-as-a-Stream-using-C-SDK/m-p/413790#M22334</link>
    <description>&lt;P&gt;No, unfortunately the API doesn't offer the ability to request a different export type,&amp;nbsp;but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Apr 2020 15:19:30 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2020-04-24T15:19:30Z</dc:date>
    <item>
      <title>Download any file as a Stream using C# SDK</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Download-any-file-as-a-Stream-using-C-SDK/m-p/412530#M22292</link>
      <description>&lt;P&gt;Hey, I'm wanting to download a file through the C# SDK, however I'm having issues when it is of the Dropbox .paper or similar cloud storage file type. I'm wanting it as a MemoryStream for my team and I to work with. Using the &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_DownloadAsync_1.htm" target="_self"&gt;DropboxClient.Files.DownloadAsync&lt;/A&gt;, I'm given an Unsupported Type error when attempting to download a .paper / .gdoc etc, but works fine with .doc / .docx. I'm given a similar error when using the &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_DownloadZipAsync_1.htm" target="_self"&gt;DownloadZipAsync&lt;/A&gt;. I saw in the docs to use &lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Files_Routes_FilesUserRoutes_ExportAsync.htm" target="_self"&gt;Export As&lt;/A&gt;. Inspecting the FileMetaData.ExportInfo only contained "html" for the .paper file I was trying to download. I've looked online for a solution but am coming up empty handed. Here is a snippet of my code.&lt;/P&gt;&lt;PRE&gt;string path = myInputs.path;
MemoryStream newStream = new MemoryStream();
try
{
    var fileObject = await dropboxClient.Files.GetMetadataAsync(path);
    if (!String.IsNullOrWhiteSpace(fileObject.AsFile.ExportInfo.ExportAs))
    {
        using (var response = await dropboxClient.Files.ExportAsync(fileObject.PathLower))
        {
            (await response.GetContentAsStreamAsync()).CopyTo(newStream);
            return newStream;
        }
    }
    else
        using(var response = await dropboxClient.Files.DownloadAsync(path)){
            (await response.GetContentAsStreamAsync()).CopyTo(newStream);
            return newStream;
        }
}&lt;/PRE&gt;&lt;P&gt;What's the best way to handle universally downloading files from dropbox, regardless of file type? I would prefer to not call GetMetaDataAsync if possible to lower API calls, but it's okay if it required for checking the ExportInfo.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 15:13:46 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Download-any-file-as-a-Stream-using-C-SDK/m-p/412530#M22292</guid>
      <dc:creator>Bobby I</dc:creator>
      <dc:date>2020-04-21T15:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Download any file as a Stream using C# SDK</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Download-any-file-as-a-Stream-using-C-SDK/m-p/412558#M22296</link>
      <description>&lt;P&gt;You have the right idea here. As you found, some cloud files, such as Paper docs, can't be downloaded via the normal Download method. You need to use Export for those instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can either just try to Download the file and catch the UnsupportedFile error, at which point you would use Export instead, or you can check the file ahead of time by calling GetMetadata like you mentioned. If you do that though, you can use&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-dotnet/html/P_Dropbox_Api_Files_FileMetadata_IsDownloadable.htm" target="_self"&gt;FileMetadata.IsDownloadable&lt;/A&gt; instead of checking&amp;nbsp;ExportAs.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 16:39:08 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Download-any-file-as-a-Stream-using-C-SDK/m-p/412558#M22296</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-04-21T16:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Download any file as a Stream using C# SDK</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Download-any-file-as-a-Stream-using-C-SDK/m-p/413641#M22330</link>
      <description>&lt;P&gt;I see. I think I will add a catch for this as you suggested and then attempt to export it. When I was attempting to export a paper file, the ExportAs value was always html. Through the Dropbox GUI, we're able to export as Markdown, Docx, or PDF. Is it possible to change how we want it to be exported programmatically? When it is html, we get a lot of extra fluff like styling and tags, when all we are realy interested in is the content.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2020 08:23:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Download-any-file-as-a-Stream-using-C-SDK/m-p/413641#M22330</guid>
      <dc:creator>Bobby I</dc:creator>
      <dc:date>2020-04-24T08:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Download any file as a Stream using C# SDK</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Download-any-file-as-a-Stream-using-C-SDK/m-p/413790#M22334</link>
      <description>&lt;P&gt;No, unfortunately the API doesn't offer the ability to request a different export type,&amp;nbsp;but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2020 15:19:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Download-any-file-as-a-Stream-using-C-SDK/m-p/413790#M22334</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-04-24T15:19:30Z</dc:date>
    </item>
  </channel>
</rss>

