Skip to main content
Back to plugins
@capgo/capacitor-file-sharer
Tutorial
by github.com/Cap-go

File Sharer

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

Guide

Tutorial on File Sharer

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