datasource.fileSize
Retrieves the size of a specified file from the MODLR filesystem.
js
datasource.fileSize(file_name)
Parameters
file_name
(string): The name of the file for which you want to retrieve the size.
Returns
number
: An integer representing the size of the file in bytes. Returns0
if the file is invalid, does not exist, or an error occurs.
Examples
js
var fileSizeInBytes = datasource.fileSize("my_file.txt");
if (fileSizeInBytes > 0) {
console.log("File size:", fileSizeInBytes, "bytes");
} else {
console.log("Error retrieving file size or invalid file.");
}