Search code examples
cordovacordova-plugin-file

cordova: FileEntry metadata are undefined


cache_dir_entry.getFile(cache.program_list_cache, {create:true}, function(cache_file_entry) {

    console.log (cache_file_entry.name);
    console.log ("-" + cache_file_entry.lastModifiedDate);
    console.log ("-" + cache_file_entry.size );
 ...
 }

I can see the file name, but both lastModifiedDate and size are undefined. Why?

Note that in the real code I'm handling the failure event of getFile and I can succesfully remove() the FileEntry, so the object and the file both exists.


Solution

  • I forgot to use the .file function

    cache_dir_entry.getFile(cache.program_list_cache, {create:true}, function(cache_file_entry) {
    
                        cache_file_entry.file(function(file) {
                            console.log (file.name);
                            console.log ("-" + file.lastModifiedDate ) ;
                            console.log ("-" + time_difference)
                            console.log ("-" + file.size ); 
                        });