capacitor-file-viewer
March 31, 2025 路 View on GitHub
@capacitor/file-viewer
The FileViewer API provides mechanisms for opening files and previewing media. Not available on web.
馃攲 Cordova Plugin
路
馃 Android Library
路
馃崗 iOS Library
Install
npm install @capacitor/file-viewer
npx cap sync
Example
import { FileViewer } from "@capacitor/file-viewer";
// can use a plugin like @capacitor/filesystem to get the full path to the file
const openDocument = async () => {
await FileViewer.openDocumentFromLocalPath({
path: "path/to/file.pdf"
});
};
// ios-specific
const previewMedia = async () => {
await FileViewer.previewMediaContentFromUrl({
path: "https://url_hosting_media/file.mp4"
});
}
API
Check the plugin's api here.