Capacitor plugin to download and share files for the Web, Android and iOS (soon)
Branch: master
Clone or download
Michael Oberwasserlechner
Latest commit d9e58a5 Feb 6, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
android
ios/ByteowlsCapacitorFilesharer
src
.editorconfig
.gitignore
ByteowlsCapacitorFilesharer.podspec
LICENSE feat(): download file in platform web Dec 19, 2018
README.md
package-lock.json
package.json
rollup.config.js
tsconfig.json feat(): download file in platform web Dec 19, 2018

README.md

Capacitor plugin for file sharing

npm npm Twitter Follow Donate

Attention: This project is an ALPHA

This library is about to be changed through development as I need it.

If you use a working version do not automatically update your dependencies.

I will NOT announce any changes until the first beta is released.

Installation

npm i @byteowls/capacitor-filesharer

Configuration

This example shows the common process of configuring this plugin.

Although it was taken from a Angular 6 application, it should work in other frameworks as well.

Register plugin

Find the init component of your app, which is in Angular app.component.ts and register this plugin by

import {registerWebPlugin} from "@capacitor/core";
import {FileSharer} from '@byteowls/capacitor-filesharer';

@Component()
export class AppComponent implements OnInit {

    ngOnInit() {
        console.log("Register custom capacitor plugins");
        registerWebPlugin(FileSharer);
        // other stuff
    }
}

Use it

import {
  Plugins
} from '@capacitor/core';

@Component({
  template: '<button (click)="downloadButtonClick()">Download file</button>'
})
export class SignupComponent {
    downloadButtonClick() {
        Plugins.FileSharer.share({
            filename: "test.pdf",
            base64Data: "...",
            contentType: "application/pdf",
        }).then(() => {
            // do sth
        }).catch(reason => {
            console.error("File sharing failed", reason);
        });
    }
}

Platform: Web/PWA

No further config is needed.

Platform: Android

Register the plugin in com.companyname.appname.MainActivity#onCreate

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        List<Class<? extends Plugin>> additionalPlugins = new ArrayList<>();
        // Additional plugins you've installed go here
        // Ex: additionalPlugins.add(TotallyAwesomePlugin.class);
        additionalPlugins.add(FileSharerPlugin.class);

        // Initializes the Bridge
        this.init(savedInstanceState, additionalPlugins);
    }

Platform: iOS

No further config is needed. On iOS the plugin is registered automatically by Capacitor.

Platform: Electron

  • Maybe early 2019

Contribute

Fix a bug or create a new feature

Please do not mix more than one issue in a feature branch. Each feature/bugfix should have its own branch and its own Pull Request (PR).

  1. Create a issue and describe what you want to do at Issue Tracker
  2. Create your feature branch (git checkout -b feature/my-feature or git checkout -b bugfix/my-bugfix)
  3. Test your changes to the best of your ability.
  4. Commit your changes (git commit -m 'Describe feature or bug')
  5. Push to the branch (git push origin feature/my-feature)
  6. Create a Github pull request

Code Style

This repo includes a .editorconfig file, which your IDE should pickup automatically.

If not please use the sun coding convention. Please do not use tabs at all!

Try to change only parts your feature or bugfix requires.

License

MIT. Please see LICENSE.

BYTEOWLS Software & Consulting

This plugin is powered by BYTEOWLS Software & Consulting and was build for Team Conductor - Next generation club management platform.

Commercial support and consulting

We create plugins for apps we build and share them as it is with the community.

I you have a feature request, need support how to using the plugin or need a release breaking with our normal release cycle you have the possibility to sponsor the development by paying for this custom development or support.

See the wiki page for how to request a quote.