How to get file size using HTML5 FileSystem interface?

How to find out the size of a file located in a local file system represented through the HTML5 API?

I expect something like that,

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

... to be accessible, but did not find anything like it.

+6
source share
1 answer

You need to call:

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

See File System Specifications Input Interface and Metadata Interface for details.

+10
source

Source: https://habr.com/ru/post/958029/


All Articles