Plugin for Cordova to use the native android SDK and the native iOS SDK of FileStack (formerly filepicker.io)
cordova plugin add cordova-plugin-filepickerio --save
The plugin creates the object window.filepicker
with the following functions available:
filepicker.setKey(key)
filepicker.setName(app_name)
filepicker.pick(picker_options, onSuccess(Blob){}, onError(FPError){})
filepicker.pickMultiple(picker_options, onSuccess(Blobs){}, onError(FPError){})
filepicker.pickAndStore(picker_options, store_options, onSuccess(Blobs){}, onError(FPError){})
container
- container in S3 where the file was stored (if it was stored)url
- file link to uploaded filefilename
- name of filelocalPath
- local path of file // not returned on iOSkey
- unique keymimetype
- mimetypesize
- size in bytes
note: pick()
returns an object, pickMultiple()
and pickAndStore()
returns an array of objects
multiple
boolean : Getting multiple filesmaxFiles
integer : Choosing max filesmaxSize
integer : Choosing max files // not supported on iOSservices
array of strings : Choosing services{"GALLERY", "CAMERA", "FACEBOOK", "CLOUDDRIVE", "DROPBOX", "BOX", "GMAIL", "INSTAGRAM", "FLICKR", "PICASA", "GITHUB", "GOOGLE_DRIVE", "EVERNOTE", "SKYDRIVE"}
mimeTypes
array of strings : Choosing mimetypes
location
string :S3
,azure
,dropbox
,rackspace
,gcs
path
string : Choosing the path"/example/123.png"
container
string : Bucketaccess
string :public
Not implemented yet, feel free to contribute. See native SDK documentation.
Not implemented yet, feel free to contribute. See native SDK documentation.
filepicker.setName(name)
- the
maxSize
picker options is not supported on iOS - the
localPath
property is not returned on iOS - the property
picker_options.multiple
for thefilepicker.pickAndStore()
function have different default value. On android, it isfalse
by default. On iOS, it istrue
.
A full example could be:
function pickFile() {
window.filepicker.setKey('APP KEY');
window.filepicker.setName('APP NAME');
window.filepicker.pickAndStore({
multiple: true,
mimeTypes: ['image/*', 'application/pdf'],
services : [ 'CAMERA', 'GALLERY', 'GOOGLE_DRIVE', 'DROPBOX', 'BOX', 'SKYDRIVE'],
maxFiles: 20,
maxSize: (10*1024*1024)
}, {
location : 'S3',
path : '/location/'
}, function(res) {
console.log(res);
}, function(e) {
console.error(e);
});
}
If you get the following error when launching your app:
dyld: Library not loaded: .framework/FSPicker
Reason: image not found
Make sure that the frameworks are correctly embedded in Xcode:
If your app is successful or if you are working for a company, please consider donating some beer money 🍺:
Keep in mind that I am maintaining this repository on my free time so thank you for considering a donation. 👍
Thanks for considering contributing to this project.
Ask, or pick an issue and comment on it announcing your desire to work on it. Ideally wait until we assign it to you to minimize work duplication.
-
Search existing issues before raising a new one.
-
Include as much detail as possible.
-
Make it clear in the issue tracker what you are working on, so that someone else doesn't duplicate the work.
-
Use a feature branch, not master.
-
Rebase your feature branch onto origin/master before raising the PR.
-
Keep up to date with changes in master so your PR is easy to merge.
-
Be descriptive in your PR message: what is it for, why is it needed, etc.
-
Make sure the tests pass
-
Squash related commits as much as possible.
-
Try to match the existing indent style.
-
Don't mix platform-specific stuff into the main code.
The MIT License
Copyright (c) 2016 Didier Baquier
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.