Taron Mehrabyan
Taron Mehrabyan

Reputation: 2229

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.

Upvotes: 7

Views: 3306

Answers (1)

Brian Campbell
Brian Campbell

Reputation: 332776

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.

Upvotes: 11

Related Questions