Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15243] iOS7: Saving file to applicationDataDirectory results in incorrect path

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-09-17T23:08:26.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsfilesystem, ios7, mobile
ReporterMarco Aiello
AssigneeShak Hossain
Created2013-09-17T08:28:01.000+0000
Updated2017-03-31T20:33:07.000+0000

Description

I use this code:
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,"test.pdf");
var ret = f.write(this.responseData);
After "f.nativePath" value is: file:///Users/marco/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/A7304977-7E4F-489D-A143-045F52975DED/MyApp.app/file:/Users/marco/Library/Application%2520Support/iPhone%2520Simulator/7.0/Applications/A7304977-7E4F-489D-A143-045F52975DED/Documents/test.pdf and i can't load this url from webview or documentviewer Any suggestion please?

Comments

  1. Ingo Muschenetz 2013-09-17

    Which version of the SDK are you using? are you using 3.1.3?

    Does the file save without error? It's just the display that is the problem?

    What if you try and manually find that URL on your computer?

    I assume this is the simulator, yes?

  2. Marco Aiello 2013-09-17

    1. ios sdk 7.0, Titanium Studio 3.1.2 GA 2. no, file is not saved! 3. folder/file not found - file not saved! 4. yes, simulator
  3. Ingo Muschenetz 2013-09-17

    Please try the latest 3.1.3 SDK (http://builds.appcelerator.com.s3.amazonaws.com/index.html#3_1_X). 3.1.2 may not work on iOS 7.
  4. Marco Aiello 2013-09-17

    I've updated Titanium with the latest SDK (3.1.3) but nothing ... always the same problem ...
  5. Ingo Muschenetz 2013-09-17

    Can you please post the updated URL you get when saving the file with 3.1.3, and the exact SDK version you are using?
  6. Vishal Duggal 2013-09-17

    This is the code we used for testing
       var url = "http://www.appcelerator.com/assets/The_iPad_App_Wave.pdf";
        var client = Ti.Network.createHTTPClient({
            // function called when the response data is available
            onload : function(e) {
                Ti.API.info("SUCCESS");
                var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,"test.pdf");
                f.write(this.responseData);
                Ti.API.info(f.nativePath);
       
                var docViewer = Ti.UI.iOS.createDocumentViewer({
                   url:f.nativePath
                })
                docViewer.show();
            },
            // function called when an error occurs, including a timeout
            onerror : function(e) {
                Ti.API.info(e.error);
            },
            timeout : 5000  // in milliseconds
        });
        // Prepare the connection.
        client.open("GET", url);
        // Send the request.
        client.send();
       
  7. kosso 2013-09-18

    Check to see if Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory is returning a trailing slash or not. I have found a couple of occasions over the past few versions of the Ti SDK where this is inconsistent, causing double-slash paths to crop in to apps here and there.
  8. kosso 2013-09-18

    Is this related? https://developer.appcelerator.com/question/153484/ios-7-compatibility-with-titanium-app#answer-264403
  9. Lee Morris 2017-03-31

    Unable to reproduce this issue, tested with the following environment; iPhone 7 and Simulator (10.2) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.2 GA Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80

JSON Source