How to check file sizes in Workday Studio

Posted 4 months ago

Recently I was looking at a Studio integration that was throwing errors for trying to occasionally send files out to a vendor that were too large (>10mb). So I was curious if I could read the file size in Workday Studio and then choose to make the API request without the file when the file was too large for the vendor to accept.

Solution

Turns out this is fairly easy to accomplish. Say that the current message in the integration is the file contents. Simply use the MVEL expression parts[0].text.bytes.length to get an integer value for the size of the file in bytes.

Example

I created a text document on my computer of ~10mb. I then base64 encoded the file and saved it as large_file_base64.txt. The original file shows as 10,485,760 bytes on my computer. The base64 encoded file shows as 13,981,016 bytes.

Then I created a quick Studio integration to test my file.

Studio Integration Screenshot

  • The write step writes out the large_file_base64.txt contents as the message.
  • A router processes each of the next two steps:
  • Route 1: The base64 encoded file bytes length is sent as an integration message. Something like - 'Base64 file bytes: ' + parts[0].text.bytes.length
  • Route 2: The base64 encoded file is decoded. Then the decoded file contents bytes length is sent as a second integration message.

And the messages match the file system file sizes!

Decoded file bytes: 10485760

Base64 file bytes: 13981016