
Listed below is a snippet of code that can be used in the index.html
file to implement the DocumentPicker API functionality.
var picker = new launchbox.DocumentPicker();
// Optionally, configure picker to pick documents only from device library ..
picker.source = "library";
// .. or try to capture new document using camera ..
picker.source = "capture";
// Optionally, filter out document types which you are interested in ..
picker.type = ["image", "video"];
// .. or ..
picker.type = "audio";
// And optionally provide some parameters :
picker.imageParams = {saveToLibrary : true, quality : 60};
picker.videoParams ...
// And finally pick document ..
picker.pick()
.then(function(fileEntry) {
// If document is picked successfully here you obtain
// instance of File API 'FileEntry' object.
// You can open it using launchbox.DocumentViewer API or
// upload it to server using launchbox.FileTransfer API.
})
.catch(function(error)) {
// Error handling.
});