@capgo/capacitor-file-picker

中文文档
8.2.7发布于 2026/10/18MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4.7万

File picker Capacitor plugin - Pick files, images, videos, and directories

原始使用文档
文档目录23 节
  1. ➡️ Get started for free
  2. Key features
  3. Why Capacitor File Picker?
  4. Documentation
  5. Compatibility
  6. Install
  7. Requirements
  8. Android media permissions and Google Play review
  9. API
  10. pickFiles(...)
  11. pickImages(...)
  12. pickVideos(...)
  13. pickMedia(...)
  14. pickDirectory()
  15. convertHeicToJpeg(...)
  16. copyFile(...)
  17. checkPermissions()
  18. requestPermissions()
  19. addListener('pickerDismissed', ...)
  20. removeAllListeners()
  21. getPluginVersion()
  22. Interfaces
  23. Type Aliases

@capgo/capacitor-file-picker

Let users pick files, images, videos and folders with the native pickers on iOS and Android, with a web fallback for files and media. Convert HEIC photos on iOS and copy picked files where you need them.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-file-picker in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-file-picker to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-file-picker for Capacitor apps

Key features

  • Files: pickFiles() picks one or more files of any type.
  • Media: pickImages(), pickVideos() and pickMedia() open the photo library picker on iOS and Android. On web they open the browser file picker filtered by type.
  • Folders: pickDirectory() returns a directory on iOS and Android.
  • HEIC and copy: convertHeicToJpeg() converts photos on iOS and copyFile() copies a picked file to a new location.
  • Picker events: a pickerDismissed listener plus storage permission helpers.
  • Platforms: iOS, Android and Web. Directory picking, HEIC conversion and file copy are native only.

Why Capacitor File Picker?

A comprehensive file picker plugin with full native support for iOS and Android:

  • Pick Files - Select any file type with MIME type filtering
  • Pick Images - Native photo library picker with multi-select
  • Pick Videos - Native video picker with duration and dimensions
  • Pick Media - Combined image and video picker
  • Pick Directory - Select folders (Android/iOS)
  • HEIC to JPEG - Convert HEIC images to JPEG (iOS only)
  • Copy Files - Copy files to new locations
  • File Metadata - Get size, dimensions, duration, and more

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/file-picker/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-file-picker` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-file-picker
npx cap sync

Requirements

  • iOS: iOS 15.0+
  • Android: API 24+ (Android 7.0+)
  • Web: Modern browsers with File API support

Android media permissions and Google Play review

This plugin is designed around user-selected picker flows such as pickFiles(), pickImages(), pickVideos(), pickMedia(), and pickDirectory(). For one-time or infrequent file, image, or video selection, use these picker methods and avoid adding broad media permissions to your app manifest.

Google Play only allows READ_MEDIA_IMAGES and READ_MEDIA_VIDEO when photo or video access is directly related to your app's core purpose and picker alternatives are not sufficient. Do not request or retain these permissions only to let a user choose files, images, or videos.

Before publishing an app that declares these permissions:

  • Make sure broad photo or video library access is required for the app's core functionality.
  • Be ready to justify why Android Photo Picker or this plugin's picker methods are not sufficient.
  • Remove broad media permissions if the app can work with user-selected files only.

If Google Play review rejects the app with a message like Photo and Video Permissions policy: Permission use is not directly related to your app's core purpose, remove the broad media permissions and rely on this plugin's picker APIs instead.

For apps coming from @capgo/capacitor-file, a custom media browser, or another broad-storage flow, the recommended alternative is @capgo/capacitor-file-picker with pickImages(), pickVideos(), pickMedia(), or pickFiles().

See Google's Photo and Video Permissions policy for the current review requirements.

API

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

pickFiles(...)

pickFiles(options?: PickFilesOptions | undefined) => Promise<PickFilesResult>

Pick one or more files from the device.

ParamTypeDescription
optionsPickFilesOptions- Options for picking files

Returns: Promise<PickFilesResult>

Since: 8.0.0


pickImages(...)

pickImages(options?: PickMediaOptions | undefined) => Promise<PickFilesResult>

Pick one or more images from the gallery. Android/iOS only. On Android, limit is enforced by the system photo picker when available (Android 13+, or Android 11-12 with the Google Play system photo picker extension). Older Android versions may allow selecting more items than limit; results are truncated to limit before they are returned.

ParamTypeDescription
optionsPickMediaOptions- Options for picking images

Returns: Promise<PickFilesResult>

Since: 8.0.0


pickVideos(...)

pickVideos(options?: PickMediaOptions | undefined) => Promise<PickFilesResult>

Pick one or more videos from the gallery. Android/iOS only. On Android, limit is enforced by the system photo picker when available (Android 13+, or Android 11-12 with the Google Play system photo picker extension). Older Android versions may allow selecting more items than limit; results are truncated to limit before they are returned.

ParamTypeDescription
optionsPickMediaOptions- Options for picking videos

Returns: Promise<PickFilesResult>

Since: 8.0.0


pickMedia(...)

pickMedia(options?: PickMediaOptions | undefined) => Promise<PickFilesResult>

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

ParamTypeDescription
optionsPickMediaOptions- Options for picking media

Returns: Promise<PickFilesResult>

Since: 8.0.0


pickDirectory()

pickDirectory() => Promise<PickDirectoryResult>

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

Returns: Promise<PickDirectoryResult>

Since: 8.0.0


convertHeicToJpeg(...)

convertHeicToJpeg(options: ConvertHeicToJpegOptions) => Promise<ConvertHeicToJpegResult>

Convert a HEIC image to JPEG format. iOS only.

ParamTypeDescription
optionsConvertHeicToJpegOptions- Options for the conversion

Returns: Promise<ConvertHeicToJpegResult>

Since: 8.0.0


copyFile(...)

copyFile(options: CopyFileOptions) => Promise<void>

Copy a file to a new location.

ParamTypeDescription
optionsCopyFileOptions- Options for copying the file

Since: 8.0.0


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

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.

Returns: Promise<PermissionStatus>

Since: 8.0.0


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

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.

Returns: Promise<PermissionStatus>

Since: 8.0.0


addListener('pickerDismissed', ...)

addListener(eventName: 'pickerDismissed', listenerFunc: PickerDismissedListener) => Promise<PluginListenerHandle>

Add a listener for the picker dismissed event. iOS only.

ParamTypeDescription
eventName'pickerDismissed'- The event name
listenerFuncPickerDismissedListener- The listener function

Returns: Promise<PluginListenerHandle>

Since: 8.0.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 8.0.0


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the native Capacitor plugin version.

Returns: Promise<{ version: string; }>

Since: 8.0.0


Interfaces

PickFilesResult

Result of picking files.

PropTypeDescription
filesPickedFile[]Array of picked files

PickedFile

Represents a picked file.

PropTypeDescription
namestringThe name of the file
pathstringThe path to the file
mimeTypestringThe MIME type of the file
sizenumberThe size of the file in bytes
datastringThe base64 encoded data of the file. Only present if readData was true.
blobBlobThe Blob instance of the file. Web only.
widthnumberWidth in pixels (images/videos only)
heightnumberHeight in pixels (images/videos only)
durationnumberDuration in seconds (videos only)
modifiedAtnumberLast modified timestamp in milliseconds

PickFilesOptions

Options for picking files.

PropTypeDescriptionDefault
typesstring[]List of accepted MIME types or file extensions. On iOS, only MIME types are supported. Examples: ['image/*'], ['application/pdf'], ['.pdf', '.doc']
limitnumberMaximum number of files to pick. Set to 0 for unlimited (platform default).0
readDatabooleanWhether to read the file data as base64. Note: Reading large files may cause memory issues.false

PickMediaOptions

Options for picking media (images/videos).

PropTypeDescriptionDefault
limitnumberMaximum number of files to pick. Set to 0 for unlimited (platform default). On Android, when the system photo picker is available, the platform enforces this limit (capped by the device maximum). On older Android versions the picker may not enforce the limit; the plugin truncates the returned list to this value when needed.0
readDatabooleanWhether to read the file data as base64. Note: Reading large files may cause memory issues.false
skipTranscodingbooleaniOS only: Skip transcoding of videos.false
orderedbooleaniOS 15+ only: Show ordered selection badges.false

PickDirectoryResult

Result of picking a directory.

PropTypeDescription
pathstringThe path to the selected directory

ConvertHeicToJpegResult

Result of HEIC to JPEG conversion.

PropTypeDescription
pathstringThe path to the converted JPEG file

ConvertHeicToJpegOptions

Options for converting HEIC to JPEG.

PropTypeDescriptionDefault
pathstringThe path to the HEIC file to convert
qualitynumberThe compression quality for JPEG (0.0 - 1.0).0.9

CopyFileOptions

Options for copying a file.

PropTypeDescriptionDefault
fromstringSource file path
tostringDestination file path
overwritebooleanWhether to overwrite if destination exists.false

PermissionStatus

Permission status for file access.

PropTypeDescription
readExternalStoragePermissionStateWhether broad external storage or media permission is granted. Picker APIs that return user-selected files usually do not require this on Android 13+.
accessMediaLocationPermissionStateWhether permission to access media location is granted

PluginListenerHandle

PropType
remove() => Promise<void>

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

PickerDismissedListener

Listener callback for picker dismissed event.

(event: null): void

版本与发布记录

@capgo/capacitor-file-picker 共发布 21 个版本,首次发布于 2025/12/16;过去 12 个月发布了 21 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.2.7latest2026/10/1821 天前
8.2.62026/10/1525 天前
8.2.52026/10/1327 天前
8.2.42026/10/091 个月前
8.2.32026/10/081 个月前
8.2.22026/10/081 个月前

关于 @capgo/capacitor-file-picker 的常见问题

@capgo/capacitor-file-picker 是什么?

File picker Capacitor plugin - Pick files, images, videos, and directories

如何安装 @capgo/capacitor-file-picker?

在项目目录运行 npm install @capgo/capacitor-file-picker,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-file-picker 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-file-picker 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-file-picker 可以商用吗?

@capgo/capacitor-file-picker 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-file-picker 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-file-picker 在 2026/10/09 – 2026/11/07 这 30 天内被下载 47,326 次,日均约 1,578 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-file-picker 还在维护吗?

最新版本 8.2.7 发布于 2026/10/18(21 天前);至今共发布 21 个版本,其中过去 12 个月发布了 21 个;首次发布于 2025/12/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。