How can I store the exact size of the file being uploaded in a variable?

I am facing a problem where I want to store the exact size of an uploading file in a variable so that I can access it later to validate even if the section containing the file upload field is hidden. I am on v19.1. PS. By size, I mean the exact size in bytes and not "<1KB" which is retrieved by using fv!files.size. I cannot use a!save() function in validation attribute and fv!files.size is not accessible outside validation.

  Discussion posts and replies are publicly visible

Parents
  • If you do not want to resort to submitting your form just to fetch the file size, there is one way to handle this all while still being on the interface. What you have to do is to create an expression rule and pass the document as a rule input. Use below code in your exp rule,

    local!fileSize:a!fileUploadField_17r1(value:ri!document).contents.size

    This will return you the size of the file which has just been uploaded and yet to be saved in the KC. Use this exp rule to conditionally submit form based on your use case.

    P.S.: I am using older version of file upload because .contents does not work with new version. One probable (mostly obvious) reason could be the change in property names. But Appian hasn't deprecated the old version yet since 17.2, so we can use it. Maybe they will allow us to access file name, size, extension, etc in the saveInto parameter in the future.

    Hope this helps!

Reply
  • If you do not want to resort to submitting your form just to fetch the file size, there is one way to handle this all while still being on the interface. What you have to do is to create an expression rule and pass the document as a rule input. Use below code in your exp rule,

    local!fileSize:a!fileUploadField_17r1(value:ri!document).contents.size

    This will return you the size of the file which has just been uploaded and yet to be saved in the KC. Use this exp rule to conditionally submit form based on your use case.

    P.S.: I am using older version of file upload because .contents does not work with new version. One probable (mostly obvious) reason could be the change in property names. But Appian hasn't deprecated the old version yet since 17.2, so we can use it. Maybe they will allow us to access file name, size, extension, etc in the saveInto parameter in the future.

    Hope this helps!

Children