目录

About This Kit

Preview Kit provides convenient file preview and opening boost functions for apps.

File Preview Scenarios

Preview Kit, catering to a majority of office development needs, enables users to preview a variety of file types including images, videos, audios, texts, and HTML pages. It provides the following capabilities:

File Open Boost Scenarios

After your document app integrates the file open boost service, it will recommend files that you may open to your app based on algorithms. The app can then preload files in the background in advance so that you can open the preloaded files in an extremely short time. This provides users with smooth file opening experience.

File Cache Boost Scenarios

When a user opens or browses a file in an app, the file cache boost function can create a cache file indexed by a specific key to store the cached data. The system performs persistent management on all caches of the app. When a user opens or browses the file again in the app, the app first searches for the corresponding cache using the key. If a cache hit occurs, the app reads the cached data directly from the disk, eliminating the need for repeated decoding. This significantly reduces repetitive decoding overhead, providing users with a seamless and smooth file opening and browsing experience.

Constraints

[h2]Supported Countries/Regions

Currently, Preview Kit is available only in the Chinese mainland.

[h2]Supported Devices

Preview Kit is supported on Huawei phones, tablets, and PCs/2-in-1 devices while the file open boost function is supported only on PCs/2-in-1 devices and tablets.

Emulator Support

This kit supports the Emulator, but there are some differences in feature support between real devices and the Emulator:

File Types Supported by File Preview

Preview Kit supports the preview of images, videos, audios, texts, and HTML files. The following table lists some common formats. You can use the canPreview API to check whether a file can be previewed.

Type File Name Extension MIME Type
Text txt, cpp, c, h, java, xhtml, and xml text/plain, text/x-c++src, text/x-csrc, text/x-chdr, text/x-java, application/xhtml+xml, and text/xml
Web page html and htm text/html
Image jpg, png, gif, webp, bmp, and svg image/jpeg, image/png, image/gif, image/webp, image/bmp, and image/svg+xml
Audio m4a, aac, mp3, ogg, and wav audio/mp4a-latm, audio/aac, audio/mpeg, audio/ogg, and audio/x-wav
Video mp4, mkv, and ts video/mp4, video/x-matroska, and video/mp2ts
Folder N/A N/A
Document pdf application/pdf
Office document doc, docx, xls, xlsx, ppt, pptx, csv, and ofd application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, text/csv, and general.ofd

File Types Supported by File Open Boost

.doc, .docx, .xls, .xlsx, .ppt, and .pptx files.

Basic Concepts of File Preview

Basic Concepts of File Cache Boost

In the file cache boost function, a key serves as the unique identifier for each cached file object and is used to manage the cached data. The key value can be generated by applying a hash algorithm to the file content. For example, you can perform a SHA-256 hash operation on an image and use the generated hash value as the key value for that image cache object.