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.
cordova plugin add https://github.com/jennielynshapiro/cordova-plugin-filestack.git --save
CocoaPods dependency manager is required for iOS https://cocoapods.org/
sudo gem install cocoapods
Add a url scheme to your info.plst https://coderwall.com/p/mtjaeq/ios-custom-url-scheme
The swift version for each framework has to me manually set in Xcode.
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>
Open the picker using
window.filestack.openFilePicker(params, callback)
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 AndroidappURLScheme
string : Url scheme for iOSlocation
string : Storage locationcontainer
string : Storage containerregion
string : Storage region
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 namesize
string int : Size in bytesmimetype
string : Mime Typehandle
string : Filestack file identifierkey
string : Storage key
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 = [];
}
});
- Currently the iOS implementation only supports appURLScheme and the Android implmentation only supports returnUrl.
- The iOS implementation does not support filtering mime types.