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

File Sharer Capacitor plugin

Share and save files from base64 data or local paths across Android, iOS, and Web

Install

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

Guide

How to use File Sharer in Capacitor

Test on device

Download the Capgo app, then scan the QR code.

File Sharer plugin preview QR code

Using @capgo/capacitor-file-sharer

Share and save files from base64 data, data URLs, local file paths, file:// URLs, Android content:// URIs, and Capacitor _capacitor_file_ URLs.

Install

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

What This Plugin Exposes

  • share - Open the native share sheet on Android and iOS, or download the file on Web.
  • save - Save to Android public collections, open the iOS save/share sheet, or download on Web.
  • getPluginVersion - Return the platform implementation version.

Example Usage

Share A Generated File

import { FileSharer } from '@capgo/capacitor-file-sharer';

await FileSharer.share({
  filename: 'report.pdf',
  contentType: 'application/pdf',
  base64Data: reportBase64,
  title: 'Quarterly report',
  text: 'Attached report',
});

Share A Local File

await FileSharer.share({
  filename: 'export.zip',
  contentType: 'application/zip',
  path: fileUri,
});

Save To Downloads On Android

const result = await FileSharer.save({
  filename: 'backup.zip',
  contentType: 'application/zip',
  base64Data: zipBase64,
  android: {
    saveDirectory: 'downloads',
    relativePath: 'Download/My App',
  },
});

console.log(result.uri);

Platform Notes

  • Android sharing uses FileProvider, ClipData, and URI grants so chooser previews and thumbnails can read the file.
  • Android saves use MediaStore on Android 10+ and public directories on Android 9 and below.
  • iOS sharing supports both base64-backed temporary files and direct local path sharing.
  • Web sharing and saving downloads the file, with chunked base64 conversion for large files.

Full Reference

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

If you are using Using @capgo/capacitor-file-sharer to plan storage and file handling, connect it with @capgo/capacitor-file-sharer for the implementation detail in @capgo/capacitor-file-sharer, 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 Sharer plugin FAQ

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

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

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

Yes. File Sharer 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-sharer 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-sharer free and open source?

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

Can I update code that uses File Sharer 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 Sharer 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