You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

le h.'s avatar
le h.
New member | Level 1
9 years ago

Cannot get thumbails from GetThumbnailAsync

I don't see any "icon","thumbail"....

using (var dbx = new DropboxClient(Token))
{
var list = await dbx.Files.ListFolderAsync(path);
foreach(var item in list.Entries)
{
list1 = await dbx.Files.GetThumbnailAsync(item.AsFile.PathLower, null, ThumbnailSize.W64h64.Instance);
RootObject obj = new RootObject();

obj.thumbail = list1.Response.........................;
arrays.Add(obj);
}
}

return arrays;
}

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The GetThumbnailAsync method gives you IDownloadResponse<FileMetadata>. As shown in the documentation there, there are three different GetContent methods you can call on the response to get the content of the thumbnail requested.

    For example, you could get the thumbnail data as a byte array by using: (in your sample though response is list1)

    response.GetContentAsByteArrayAsync()
  • le h.'s avatar
    le h.
    New member | Level 1

    .I can't. Can you write code clearly? I don't know whatever you said.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    [Cross-linking for reference: https://stackoverflow.com/questions/35743478/how-to-get-thumbnails-for-image-dropbox-sdk-c-sharp ]

    Here's a simple example that works for me to save a thumbnail of a file in Dropbox at "/test.jpg" to a local file on my computer:

    public async Task GetThumbnail(string path)
    {
    using (var response = await client.Files.GetThumbnailAsync(path, null, ThumbnailSize.W64h64.Instance))
    {
    using (var fileStream = File.Create ("/destination/path/test_thumb.jpg")) {
    var thumbStream = await response.GetContentAsStreamAsync();
    thumbStream.CopyTo (fileStream);
    };
    }
    }

    await GetThumbnail("/test.jpg");

    Just be sure to set your remote path and local destination accordingly.

  • le h.'s avatar
    le h.
    New member | Level 1

    your mean that I have to convert byte to getting thumbnail.

    GetContentAsStringAsync():

    Result = "����\0\u0010JFIF\0\u0001\u0001\0\0\u0001\0\u0001\0\0��\0C\0\u0006\u0004\u0005\u0006\u0005\u0004\u0006\u0006\u0005\u0006\a\a\u0006\b\n\u0010\n\n\t\t\n\u0014\u000e\u000f\f\u0010\u0017\u0014\u0018\u0018\u0017\u0014\u0016\u0016\u001a\u001d%\u001f\u001a\u001b#\...

     

    GetContentAsByteArrayAsync():

    Result = {byte[1674]}