Git Product home page Git Product logo

cordova-plugin-filestack's Introduction

Filestack Cordova

Filestack plugin for Cordova. Available for Android and iOS

Combines Filestack's native Android (https://github.com/filestack/filestack-android) and iOS (https://github.com/filestack/filestack-ios) SDKs into a Cordova plugin.

A completely rewritten version of https://github.com/dbaq/cordova-plugin-filepickerio. The iOS native library used in that project has been depreciated. The Android implementation does not support app links wich is required for at least Google oAuth flows.

Installing the plugin

cordova plugin add https://github.com/jennielynshapiro/cordova-plugin-filestack.git --save

iOS Setup

Installing CocoaPods

CocoaPods dependency manager is required for iOS https://cocoapods.org/

sudo gem install cocoapods

URL Scheme

Add a url scheme to your info.plst https://coderwall.com/p/mtjaeq/ios-custom-url-scheme

Framework Swift Version in Xcode

The swift version for each framework has to me manually set in Xcode.

Android Setup

App Links

App links should be setup and working. https://developer.android.com/training/app-links/

Set the APP_LINK_HOST variable in your config.xml

<plugin name="cordova-plugin-filestack" spec="https://github.com/jennielynshapiro/cordova-plugin-filestack.git">
   <variable name="APP_LINK_HOST" value="demo.filestack.com" />
</plugin>

Usage

Open the picker using

window.filestack.openFilePicker(params, callback)

Params

  • apiKey string : Your filestack api key.
  • sources string array : An array of sources.
  • mimeTypes string array : An array of mime type selector.
  • returnUrl string : App link for Android
  • appURLScheme string : Url scheme for iOS
  • location string : Storage location
  • container string : Storage container
  • region string : Storage region

Response

The callback should accept (error, result). Result is an object with a file object property and a boolean complete property. The callback will be called once for each file uploaded. The last callback will have the complete property set to true.

File Properties:

  • filename string : File name
  • size string int : Size in bytes
  • mimetype string : Mime Type
  • handle string : Filestack file identifier
  • key string : Storage key

Example

 let files = [];

      window.filestack.openFilePicker({
        apiKey: "YOUR_API_KEY",
        sources: ["device", "googledrive", "facebook", "instagram", "dropbox", "box", "github", "gmail", "picasa", "onedrive", "clouddrive"],
        mimeTypes: ["*/*"],
        returnUrl: "https://demo.filestack.com",
        appURLScheme: "filestack",
        location: "S3",
        container: "my-bucket-name",
        region: "us-west-2"
      }, (err, result) => {

        if(err) {
          // Handle Error
          return;
        }

        if(!result) {
          return;
        }

        if(result.file) {
          files.push(result.file);
        }

        if(files.length > 0 && result.complete) {
          onFilestackUploadDone({filesUploaded: files});
          files = [];
        }

      });

Notes

  • Currently the iOS implementation only supports appURLScheme and the Android implmentation only supports returnUrl.
  • The iOS implementation does not support filtering mime types.

cordova-plugin-filestack's People

Contributors

jennielynshapiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

graemian

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.