Skip to main content
@capgo/capacitor-file-picker Files & Storage Open source

File Picker Capacitor plugin

Pick files, images, videos, and directories with full native support for iOS and Android including HEIC conversion

Install

bun add @capgo/capacitor-file-picker bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-file-picker
  • pnpm add @capgo/capacitor-file-picker
  • yarn add @capgo/capacitor-file-picker

Guide

How to use File Picker in Capacitor

Using @capgo/capacitor-file-picker

Capacitor File Picker Plugin interface for selecting files, images, videos, and directories.

Install

bun add @capgo/capacitor-file-picker
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { CapgoFilePicker } from '@capgo/capacitor-file-picker';

API at a glance

Method Description
pickFiles Pick one or more files from the device.
pickImages Pick one or more images from the gallery. Android/iOS only.
pickVideos Pick one or more videos from the gallery. Android/iOS only.
pickMedia Pick one or more images or videos from the gallery. Android/iOS only.
pickDirectory Pick a directory from the device. Android/iOS only.
convertHeicToJpeg Convert a HEIC image to JPEG format. iOS only.
copyFile Copy a file to a new location.
checkPermissions Check broad storage or media permission state. Picker-only flows should not gate pickFiles(), pickImages(), pickVideos(), or pickMedia() on this permission on Android 13+. Android only.
requestPermissions Request broad storage or media permissions. Do not request or declare READ_MEDIA_IMAGES or READ_MEDIA_VIDEO only to use picker APIs. Google Play allows these permissions only when picker alternatives are not sufficient for core app functionality. Use @capgo/capacitor-file-picker picker methods instead for user-selected file, image, or video access. Android only.

Examples

pickFiles()

Pick one or more files from the device.

import { CapgoFilePicker } from '@capgo/capacitor-file-picker';

const result = await CapgoFilePicker.pickFiles({
  types: ['application/pdf', 'image/*'],
  limit: 5,
  readData: false
});
console.log('Picked files:', result.files);

pickImages()

Pick one or more images from the gallery. Android/iOS only.

import { CapgoFilePicker } from '@capgo/capacitor-file-picker';

const result = await CapgoFilePicker.pickImages({
  limit: 10,
  readData: false
});
console.log('Picked images:', result.files);

pickVideos()

Pick one or more videos from the gallery. Android/iOS only.

import { CapgoFilePicker } from '@capgo/capacitor-file-picker';

const result = await CapgoFilePicker.pickVideos({
  limit: 3,
  skipTranscoding: true
});
console.log('Picked videos:', result.files);

pickMedia()

Pick one or more images or videos from the gallery. Android/iOS only.

import { CapgoFilePicker } from '@capgo/capacitor-file-picker';

const result = await CapgoFilePicker.pickMedia({
  limit: 5,
  readData: true
});
console.log('Picked media:', result.files);

pickDirectory()

Pick a directory from the device. Android/iOS only.

import { CapgoFilePicker } from '@capgo/capacitor-file-picker';

const result = await CapgoFilePicker.pickDirectory();
console.log('Selected directory:', result.path);

convertHeicToJpeg()

Convert a HEIC image to JPEG format. iOS only.

import { CapgoFilePicker } from '@capgo/capacitor-file-picker';

const result = await CapgoFilePicker.convertHeicToJpeg({
  path: '/path/to/image.heic',
  quality: 0.9
});
console.log('Converted file:', result.path);

The table above lists the 9 core methods. Listener and version helpers, and the full contract of each method, are documented in the GitHub repository.

Listen to events

addListener returns a handle. Call handle.remove() when the screen unmounts, or CapgoFilePicker.removeAllListeners() to clear every listener.

Full reference

Keep going from Using @capgo/capacitor-file-picker

If you are using Using @capgo/capacitor-file-picker to plan storage and file handling, connect it with @capgo/capacitor-file-picker for the implementation detail in @capgo/capacitor-file-picker, Getting Started for the implementation detail in Getting Started, @capgo/capacitor-data-storage-sqlite for the implementation detail in @capgo/capacitor-data-storage-sqlite, Using @capgo/capacitor-data-storage-sqlite for the native capability in Using @capgo/capacitor-data-storage-sqlite, and @capgo/capacitor-file for the implementation detail in @capgo/capacitor-file.

FAQ

File Picker plugin FAQ

How do I install the File Picker plugin in a Capacitor app?

Run "bun add @capgo/capacitor-file-picker" (or "npm install @capgo/capacitor-file-picker"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-file-picker" in your app code.

Does @capgo/capacitor-file-picker work with React, Vue and Angular?

Yes. File Picker is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-file-picker support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-file-picker free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-file-picker/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses File Picker without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship File Picker changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo