Sidebar

Is there a way to retrieve certain metadata of a file such as file size?

0 votes
180 views
asked Aug 21, 2023 by nathan-b-7857 (330 points)
Looking to see if there's a function like the below:
qie.getFileName();

In which I can retrieve the size of an associated file.

The source connector is an FTP retriever.

2 Answers

0 votes
You can use the length property of message.getBytes() to get the size of the current message in bytes.  For example, the below would store the file size in a variable called fileSize:

var fileSize = message.getBytes().length;
answered Aug 22, 2023 by jon-t-7005 (8,110 points)
0 votes

If you are looking for the size of a file that is on the disk you can use the following:

var file = new java.io.File("/filePath");

if (file.exists() && file.isFile()) {
   var fileSizeInBytes = file.length();
   qie.debug('fileSizeInBytes: ' + fileSizeInBytes);
}

answered Nov 8 by brandon-w-8204 (33,900 points)
...