925
Views
4
Comments
Solved
Is there a way to check binary file size in a client action in react?
Question

Is there a way to check binary data file size (from the upload widget) on client side vs sending the whole binary to a server action to check it?

2023-02-20 18-27-41
Gonçalo Soares
Solution

Given an Upload widget named "FileUpload":


You can use the following JavaScript snippet to extract file size information in Bytes:

var fileInputElem = document.getElementById($parameters.FileUploadId);
$parameters.FileSizeBytes = fileInputElem.files[0].size;


Passing the Widgets.FileUpload.Id as parameter to the JS Snippet:



2024-04-17 11-00-27
Wouter Kok

This does not seem to work anymore. I get:

Cannot read properties of undefined (reading '0')

2024-04-17 11-00-27
Wouter Kok


I found another solution that worked for me:
https://www.outsystems.com/forums/discussion/95463/binary-data-size/ 

The solution is in the given OML.

2017-08-09 12-12-29
Jason Herrington

The above works and I found that the binary data actions react forge component also just (or since I last updated it) updated to include a react client side file size action.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.