
The FileViewer API provides mechanisms for opening files and previewing media. Not available on web.
🔌 Cordova Plugin
·
🤖 Android Library
·
🍏 iOS Library
npm install @capacitor/file-viewer
npx cap sync
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"
});
}
Check the plugin's api here.