Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19223] iOS: Ti.Filesystem.File is undefined

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2016-11-02T11:43:31.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsios
ReporterÁngel Flores
AssigneeEric Merriman
Created2015-07-10T07:37:38.000+0000
Updated2017-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.

Comments

  1. Hans Knöchel 2015-09-09

    [~angelf] Can you provide a more specific demo code?
  2. Ángel Flores 2015-09-09

    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; }
  3. Hans Knöchel 2015-09-11

    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!
  4. Hans Knöchel 2016-11-02

    As said last year, the Ti.Filesystem.File is an abstract type and should therefore not return a specific value without the file-context of Ti.Filesystem.getFile("<directory>", "<file>")
  5. Lee Morris 2017-03-21

    Closing ticket as invalid.

JSON Source