Could not upload “zero size”. Reason: This file is empty

I am getting the below error message when I tried to upload zero size document.Though I am validating size of the file, getting the below error message:

An Error Has Occurred

Could not upload “zero size”. Reason: This file is empty

How can I remove this error message?

sample code :


load(
local!FileSize:0,
local!fileName,
a!formLayout(
label: "Upload Document Sample",
firstColumnContents: {
a!fileUploadField(
label: "File Upload",
labelPosition: "ABOVE",
instructions: "",
target:"Temporary Documents",
value: fileName,
saveInto: {
fileName,
a!save(local!FileSize,a!fileUploadField(value:fileName).uploadedDocumentSize)


},
validations: {

if(FileSize<=0,"Error, file size",null )
}
),

},

secondColumnContents: {
/* Add components here for a two-column form */
},
buttons: a!buttonLayout(
primaryB...

OriginalPostID-224673

OriginalPostID-224673

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    The ".uploadedDocumentSize" property you're using to attempt to validate on the file size, while it might possibly allow you to do what you're after, will require a little more work first. The main issue is that it returns a text value, not numeric. It returns the exact value that's shown on the Upload component after a file is uploaded, in fact. When I try it myself with an empty text file, the "size" value comes back as "< 1 KB". You can see this if you add a new text field after your file upload field and set its value to local!FileSize.

    As far as I know, Appian disallows uploading completely empty files, like even if you try to upload one yourself in "Documents" in /designer it will still fail with an error message. I'm unclear on what exactly your requirement is but you might need to take a different approach.
Reply
  • 0
    Certified Lead Developer
    The ".uploadedDocumentSize" property you're using to attempt to validate on the file size, while it might possibly allow you to do what you're after, will require a little more work first. The main issue is that it returns a text value, not numeric. It returns the exact value that's shown on the Upload component after a file is uploaded, in fact. When I try it myself with an empty text file, the "size" value comes back as "< 1 KB". You can see this if you add a new text field after your file upload field and set its value to local!FileSize.

    As far as I know, Appian disallows uploading completely empty files, like even if you try to upload one yourself in "Documents" in /designer it will still fail with an error message. I'm unclear on what exactly your requirement is but you might need to take a different approach.
Children
No Data