Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1778] Android: Add Method to TiBlob for Retrieving Underlying File

GitHub Issuen/a
TypeNew Feature
Resolution Date2011-04-17T01:57:08.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0 M03
Labelsandroid, feature
ReporterDon Thorp
AssigneeBill Dawson


See http://developer.appcelerator.com/helpdesk/view/42281">Helpdesk 42281. Add a method to TiBlob.getFile() that returns the underlying file if it exists. If the TiBlob is not a reference to a file return null.


  1. Bill Dawson 2011-04-15

    From the developer-facing API perspective, the right thing to do here would be to return a FileProxy. However, TiBlob lives in the titanium project (non-module), which to date has no references to our modules.

    What do you think is the right way to handle this? Return a TiFile, which lacks API documentation?

  2. Don Thorp 2011-04-15

    Maybe we should just documenting returning a path that can be passed to the filesystem API to get a file object. Would that suffice?

  3. Bill Dawson 2011-04-15

    .nativePath it is.

  4. Bill Dawson 2011-04-15

    Setting back to "new" while not working on it. Still have no idea how to get a file path from a content url, and sick of looking for it for now.

  5. Bill Dawson 2011-04-15

    (from [c5979f87e17694a280d1181d6aafeda399c42d52]) [#1778 state:open] Give TiBlob a nativePath property, but still need it to handle content:// urls in such a way as to be useful to users wnating to create file proxies with it. https://github.com/appcelerator/titanium_mobile/commit/c5979f87e17694a280d1181d6aafeda399c42d52"> https://github.com/appcelerator/titanium_mobile/commit/c5979f87e176...

  6. Bill Dawson 2011-04-15

    (from [36832a4b1976704db3bc1c37120a6950d157039d]) [#1778 state:fixed-in-qa] New .nativePath property will resolve content urls to paths https://github.com/appcelerator/titanium_mobile/commit/36832a4b1976704db3bc1c37120a6950d157039d"> https://github.com/appcelerator/titanium_mobile/commit/36832a4b1976...

  7. Bill Dawson 2011-04-15

    Bear with me while I make a test case - coming soon

  8. Bill Dawson 2011-04-15

    QA: here is an app.js you can use to test this. I'm morphing it into a drillbit test as well, to be committed soon:

       var win = Titanium.UI.createWindow({  
           exitOnClose: true
       var console = Ti.UI.createLabel({
           left:0, right:0, top: 0, height: 400,
           backgroundColor: 'black', color: 'white',
           font: {fontSize: 12}, verticalAlign: 'top'
       function w(s){
           if (console.text && console.text.length > 0) {
               console.text = console.text+ '\n\n* ' + s;
           } else {
               console.text = '* ' + s;
       var filename = 'blobtest';
       var testphrase = 'Revenge of the Blob';
       w('getting file with path segments ' + Ti.Filesystem.applicationDataDirectory + ', ' + filename);
       var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, filename);
       if (file.exists()) {
           w('file exists.  deleting it.');
       } else {
           w('file did not exist -- no need to delete it.');
       w('putting text "' + testphrase + '" into file');
       w('getting blob based on file');
       var blob = file.read();
       w('destroying original file variable instance to test getting it back via blob');
       file = null;
       var path = blob.nativePath;
       w("blob says file's path is " + path);
       w("getting new file instance based on that path");
       file = Ti.Filesystem.getFile(path);
       if (file.exists()) {
           w("Good - file is said to exist when I get it from that path.");
           w("Will read contents and see if they match the phrase we put in earlier.");
           var readphrase = file.read().text;
           w('Read this text: "' + readphrase + '"');
           if (testphrase === readphrase) {
               w('Yay! The phrases match.  TEST SUCCESSFUL');
           } else {
               w('FAIL!  The phrases do not match.  Something is wrong.');
       } else {
           w("FAIL - file is said to not exist.  Something is wrong.");
  9. Bill Dawson 2011-04-15

    (from [49374740a28357a89073e187edd5d57a99b0d296]) [#1778][#2553] Unit test for new blob.nativePath property https://github.com/appcelerator/titanium_mobile/commit/49374740a28357a89073e187edd5d57a99b0d296"> https://github.com/appcelerator/titanium_mobile/commit/49374740a283...

  10. Bill Dawson 2011-04-15

    (from [cad3cbee2789d5bb34454a80e85d81bf451f73c4]) [#1778][#2553] Unit test for new blob.nativePath property https://github.com/appcelerator/titanium_mobile/commit/cad3cbee2789d5bb34454a80e85d81bf451f73c4"> https://github.com/appcelerator/titanium_mobile/commit/cad3cbee2789...

  11. Thomas Huelbert 2011-04-15

    G2 2.2 RC2. Bill you rock

JSON Source