The the native document pickers (iOS / Android) to select files from the local device, iCloud (iOS) and Google Storage (Android).
- Both modules may not have full parity on the file selection
import TiDocumentPicker from 'ti.documentpicker';
const win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
const btn = Ti.UI.createButton({
title: 'pick'
});
btn.addEventListener('click', () => {
TiDocumentPicker.showDocumentPicker({
types: (OS_ANDROID) ? ['application/pdf', 'audio/mpeg'] : ['com.adobe.pdf', 'public.jpeg', 'public.png'],
allowMultiple: true,
onSelect: result => {
Ti.API.info('Files - ' + JSON.stringify(result.documents));
if (OS_ANDROID && !result.success) {
alert(result.message);
}
},
});
})
win.add(btn);
win.open();
- showDocumentPicker():
- parameter:
types: String array e.g.
['application/pdf']
and['com.adobe.pdf']
allowMultiple: boolean to allow multi file selection onSelect: callback function. Returnsresult.documents
directoryURL (iOS only): String with folder name shouldShowFileExtensions (iOS only): boolean to show extensions or not
MIT
Hans Knöchel