/ SDKs / Unity
SDKs
Chat SDKs Unity v4
Chat SDKs Unity
Chat SDKs
Unity
Version 4

Generate thumbnails of a file message

Copy link

When sending an image file, you can determine whether to create thumbnails of the image to fetch and render into your UI. You can specify up to three different sizes for thumbnail images.

Note: Supported file types are image/* and video/*. The Chat SDK doesn't support creating thumbnails when sending a file message via URL.

The SendFileMessage method requires passing a SbFileMessageCreateParams object as an argument to its parameter. It contains an array of ThumbnailSizes objects which specify the maximum values of width and height of each thumbnail image. The inCompletionHandler callback subsequently returns the array of ThumbnailSizes objects that contain the URL of each generated thumbnail image file.

A thumbnail image is generated to fit within the bounds of the provided MaxWidth and MaxHeight. If the size of the original image is smaller than the specified dimensions, the original image will have the width and height of the specified dimensions. The URL of the thumbnail returns the location of the generated thumbnail file within the Sendbird server.

SbFileMessageCreateParams createParams = new SbFileMessageCreateParams(FILE);
createParams.ThumbnailSizes = new List<SbThumbnailSize> 
{
    new SbThumbnailSize(100, 100),
    new SbThumbnailSize(40, 40)
};

channel.SendFileMessage(
    createParams, 
    inProgressHandler: null, 
    (inMessage, inError) => 
    {
        if (inError != null)
        {
            return; // Handle error.
        }
    });