Skip to content

Capacitor File Opener. The plugin is able to open a file given the mimeType and the file uri. This plugin is similar to cordova-plugin-file-opener2 without installation support.

License

Notifications You must be signed in to change notification settings

de-dan/file-opener

 
 

Repository files navigation


File Opener

@capacitor-community/file-opener

Capacitor File Opener. The plugin is able to open a file given the mimeType and the file uri.


Table of Contents

Maintainers

Maintainer GitHub Active
ryaa ryaa yes

About

This plugin is similar to cordova-plugin-file-opener2 but without installation support. The plugin supports Android platform only.

Installation

npm install @capacitor-community/file-opener
npx cap sync

API

open(...)

open(options: FileOpenerOptions) => Promise<void>

Method to open a file.

Param Type
options FileOpenerOptions

Since: 1.0.0


Interfaces

FileOpenerOptions

file open method options

Prop Type Description Since
filePath string file path 1.0.0
contentType string MIME type (optional) 1.0.0
openWithDefault boolean Use the default platform chooser, if true, otherwise: On Android: it will show "Open File in.." title of the chooser dialog, the system will always present the chooser dialog even if the user has chosen a default one and if no activity is found to handle the file, the system will still present a dialog with the specified title and an error message No application can perform this action On iOS: it will presents a menu restricted to a list of apps capable of opening the current document. This determination is made based on the document type and on the document types supported by the installed apps. To support one or more document types, an app must register those types in its Info.plist file using the CFBundleDocumentTypes key. (optional) default value is true 1.0.0

List of Error Codes and Meanings

When an error is thrown, one of the following codes (as a string value) will be used.

Code Description
'1' INTERNAL_ERROR
'2' INVALID_ARGUMENT
' '8' FILE_NOT_SUPPORTED
'9' FILE_NOT_FOUND
'10' UNKNOWN

Android

If you app needs to open files in the external directories, then within your AndroidManifest.xml file, change the following:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example">

+  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

</manifest>

About

Capacitor File Opener. The plugin is able to open a file given the mimeType and the file uri. This plugin is similar to cordova-plugin-file-opener2 without installation support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 44.8%
  • Java 29.7%
  • TypeScript 10.9%
  • Ruby 6.7%
  • Objective-C 4.6%
  • JavaScript 3.3%