Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I retrieve a file's size using the HTML5 FileSystem interface?

How might I learn the size of a file located in a local filesystem exposed through the HTML5 API?

I'm expecting something along the lines of,

 fileSystem.root.getFile(path, { create: false }, function (fileEntry) {
       //    fileEntry.size - ????????

        });

...to be available, but haven't found anything like it.

like image 377
Taron Mehrabyan Avatar asked Nov 13 '13 21:11

Taron Mehrabyan


1 Answers

You need to call:

fileEntry.getMetadata(function(metadata) { 
    alert(metadata.size); // or do something more useful with it...
});

See the specifications for the filesystem Entry interface and Metadata interface for details.

like image 127
Brian Campbell Avatar answered Sep 20 '22 13:09

Brian Campbell