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 DropboxClient.Files.DownloadAsync, 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 DownloadZipAsync. I saw in the docs to use Export As. 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.
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;
}
}
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.