Implementing Thumbnails Support in Virtual File System
The IT Hit User File System provides integrated thumbnails support on both Windows and macOS. Below we will describe how to implement thumbnails that are displayed in both Windows Explorer and macOS Finder. Note that Windows requires additional steps for registering and running the thumbnail handler.
The functionality described in this article is available in IT Hit User File System v5 Beta and later versions.
To support thumbnails you must implement the IFileSystemItem.GetThumbnailAsync() method and return your thumbnail bitmap from it:
public async Task<byte[]> GetThumbnailAsync(uint size) { byte[] thumbnail = null; string pathRemote = ThumbnailGeneratorUrl.Replace("{width}", "" + size); pathRemote = filePathRemote.Replace("{height}", "" + size); pathRemote = filePathRemote.Replace("{path}", RemoteStorageUriById); using (IWebResponse response = await DavClient.DownloadAsync(new Uri(pathRemote))) { using (Stream stream = await response.GetResponseStreamAsync()) { thumbnail = await StreamToByteArrayAsync(stream); } } string thumbnailResult = thumbnail != null ? "Success" : "Not Implemented"; Logger.LogMessage($"Thumbnail: {thumbnailResult}", UserFileSystemPath); return thumbnail; }