npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@capgo/capacitor-file-sharer

v8.1.3

Published

Capacitor plugin for sharing and saving files on Android, iOS, and Web.

Readme

@capgo/capacitor-file-sharer

Capacitor plugin for sharing and saving files on Android, iOS, and Web.

Compatibility

| Plugin version | Capacitor compatibility | Maintained | | -------------- | ----------------------- | ---------- | | v8.. | v8.. | Yes | | v7.. | v7.. | On demand | | v6.. | v6.. | On demand |

The plugin major version follows the Capacitor major version. New work targets Capacitor 8 first.

Install

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

Usage

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 from a local file path or Capacitor file URL:

await FileSharer.share({
  filename: 'movie.mp4',
  contentType: 'video/mp4',
  path: fileUri,
});

Save directly on Android or download on Web:

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

console.log(result.uri);

Integration Notes

Android

  • Sharing uses a FileProvider, ClipData, and URI grants so Android's chooser can read previews and thumbnails.
  • share() resolves after the Android chooser opens. This avoids retaining large base64 payloads in activity state.
  • save() writes to MediaStore on Android 10+ and to the matching public directory on older Android versions.
  • Android 9 and below require WRITE_EXTERNAL_STORAGE for public saves; the plugin manifest includes it with maxSdkVersion=28.
  • Android save directories: downloads, pictures, movies, music, and documents.

iOS

  • share() supports base64Data and direct local path sharing.
  • save() opens the native share sheet so the user can choose Save to Files or another destination.
  • Swift Package Manager and CocoaPods are both supported.

Web

  • share() and save() download the file in the browser.
  • Base64 conversion is chunked to avoid large-array allocation failures in Chromium.

Error Codes

  • ERR_PARAM_NO_FILENAME: filename is missing or blank.
  • ERR_PARAM_NO_DATA: neither base64Data nor path was provided.
  • ERR_PARAM_DATA_INVALID: base64 input could not be decoded.
  • ERR_LOCAL_FILE_NOT_FOUND: the provided local path or content URI could not be opened.
  • ERR_FILE_CACHING_FAILED: the native temporary file could not be written.
  • ERR_FILE_SAVE_FAILED: Android could not save the file to public storage.
  • ERR_ACTIVITY_NOT_FOUND: Android could not open a share target.
  • USER_CANCELLED: iOS share sheet was dismissed without completing.

API

Capacitor File Sharer plugin.

share(...)

share(options: ShareFileOptions) => Promise<void>

Share a file using the native share sheet on Android and iOS. On web, this downloads the file because browsers do not expose a consistent native file share target.

| Param | Type | | ------------- | ------------------------------------------------------------- | | options | ShareFileOptions |


save(...)

save(options: SaveFileOptions) => Promise<SaveFileResult>

Save a file locally. On Android this writes to MediaStore/Downloads. On web this downloads the file. On iOS this opens the share sheet so the user can choose Save to Files or another target.

| Param | Type | | ------------- | ------------------------------------------------------------- | | options | ShareFileOptions |

Returns: Promise<SaveFileResult>


getPluginVersion()

getPluginVersion() => Promise<PluginVersionResult>

Returns the platform implementation version marker.

Returns: Promise<PluginVersionResult>


Interfaces

ShareFileOptions

Options used to share a file.

| Prop | Type | Description | | ----------------- | ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | | filename | string | File name presented to the receiving app. Include the extension. | | base64Data | string | Base64 encoded file data. Data URL prefixes are accepted. | | path | string | Local file path, file:// URL, content:// URL, or Capacitor capacitor_file URL. | | contentType | string | MIME type of the file. Defaults to application/octet-stream when omitted. | | text | string | Optional text or caption shared with the file. | | title | string | Optional title for the share sheet or shared item. | | subject | string | Optional subject used by mail and compatible share targets. | | android | AndroidFileSharerOptions | Android-specific options. |

AndroidFileSharerOptions

Android-specific behavior for file sharing and saving.

| Prop | Type | Description | | ------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------ | | chooserTitle | string | Title shown at the top of the Android chooser. | | saveDirectory | AndroidSaveDirectory | Public collection used by save(). Defaults from contentType. | | relativePath | string | Optional relative folder inside the selected public collection on Android 10+. |

SaveFileResult

Result returned by save().

| Prop | Type | Description | | --------- | ------------------- | ------------------------------------------------------------ | | uri | string | Native URI of the saved file when the platform provides one. |

PluginVersionResult

Plugin version payload.

| Prop | Type | Description | | ------------- | ------------------- | ----------------------------------------------------------- | | version | string | Version identifier returned by the platform implementation. |

Type Aliases

AndroidSaveDirectory

Android public collection used by save().

'downloads' | 'pictures' | 'movies' | 'music' | 'documents'

SaveFileOptions

Options used to save a file locally.

ShareFileOptions

Contributing

See CONTRIBUTING.md.

License

MPL-2.0