files/en-us/web/api/filesystementry/getmetadata/index.md
{{APIRef("File and Directory Entries API")}}{{Deprecated_Header}}{{Non-standard_Header}}
The {{domxref("FileSystemEntry")}} interface's method
getMetadata() obtains a
{{domxref("Metadata")}} object with information about the file system entry, such as
its modification date and time and its size.
getMetadata(successCallback)
getMetadata(successCallback, errorCallback)
successCallback
errorCallback {{optional_inline}}
None ({{jsxref("undefined")}}).
DOMException.NOT_FOUND_ERR
DOMException.SECURITY_ERR
This example checks the size of a log file in a temporary folder and, if it exceeds a megabyte, 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,
);
{{Compat}}