FileSystemEntry: getMetadata() method
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see thecompatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.
TheFileSystemEntry interface's methodgetMetadata() obtains aMetadata object with information about the file system entry, such asits modification date and time and its size.
In this article
Syntax
getMetadata(successCallback)getMetadata(successCallback, errorCallback)Parameters
successCallbackA function which is called when the copy operation is successfully completed.Receives a single input parameter: a
Metadataobject with informationabout the file.errorCallbackOptionalAn optional callback which is executed if an error occurs while looking up themetadata. There's a single parameter: a
DOMExceptiondescribing what wentwrong.
Return value
None (undefined).
Exceptions
DOMException.NOT_FOUND_ERRThe
FileSystemEntryrefers to an item which doesn't exist.DOMException.SECURITY_ERRSecurity restrictions prohibit obtaining the requested metadata.
Examples
This example checks the size of a log file in a temporary folder and, if it exceeds amegabyte, moves it into a different directory.
workingDirectory.getFile( "tmp/log.txt", {}, (fileEntry) => { fileEntry.getMetadata((metadata) => { if (metadata.size > 1048576) { workingDirectory.getDirectory( "log", {}, (dirEntry) => { fileEntry.moveTo(dirEntry); }, handleError, ); } }); }, handleError,);