AppWerft / Ti.FilePicker

Titanium module for retreiving files from file system
Other
5 stars 7 forks source link

Ti.FilePicker

This module written by Jorge and Rainer    is an Titanium Android module for picking files from device.

Interface

var FilePicker = require("ti.filepicker");
FilePicker.getFileSelectDialog({
  mimeTypes: ["*/pdf"],
  suffix : ".pdf", 
  resultType : FilePicker.TYPE_FILE, 
  destinationStorage : FilePicker.TEMP_STORAGE, // or EXTERNAL_STORAGE
  onSuccess : function(_e) {
    var resultFile = _e.file;
  }  
});

In case of file result you can choose the destination with property destinationStorage In case of EXTERNAL_STORAGE don't forget to remove later … For usage of external storage on devices ≥ Marshmellow you need

  1. entry in manifest
  2. run time permissions

Or:

var FilePicker = require("ti.filepicker");
FilePicker.getFileSelectDialog({
    mimeTypes: ["*/pdf"],

    resultType : FilePicker.TYPE_BLOB
    onSuccess : function(_e) {
        var resultBlob = _e.blob;
    }
});