[TIMOB-19223] iOS: Ti.Filesystem.File is undefined
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2016-11-02T11:43:31.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | ios |
Reporter | Ángel Flores |
Assignee | Eric Merriman |
Created | 2015-07-10T07:37:38.000+0000 |
Updated | 2017-03-21T21:02:36.000+0000 |
Description
In iOS
Ti.API.info("Ti.Filesystem.File is " + Ti.Filesystem.File);
returns undefined, so you can not do something like
if ( url instanceof Ti.Filesystem.File )
It works in Android.
[~angelf] Can you provide a more specific demo code?
Before downloading a file (e.g an image), I check if it is cached or not. In order to reuse code, this function is called even when 'url' is a file path in which case I return the file. When the file is not cached, I return a file object where the image must be downloaded (using the name in the url). exports.isInCache = function (url) { if(url instanceof Ti.Filesystem.File)//This is what I really use --> if(url.indexOf("file:///")==0) { url=url.replace(/%20/g, " "); return Ti.Filesystem.getFile(url); } var filename = url.substring(url.lastIndexOf("/")+ 1, url.length); finalName= userFolder + filename; var basePath = Titanium.Filesystem.applicationDataDirectory; f = Ti.Filesystem.getFile(basePath, finalName); if(!f && !f.exists()) { var t; //code to check if the file is in the external storage and create 'userFolder' if it is needed. } return f; }
As documented, you should call
Ti.FileSystem.getFile()
, can you try that? The Ti.Filesystem.File is not supposed to work without being associated to an url. Thank you!As said last year, the
Ti.Filesystem.File
is an abstract type and should therefore not return a specific value without the file-context ofTi.Filesystem.getFile("<directory>", "<file>")
Closing ticket as invalid.