Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
20 replies
Subscribers
7 subscribers
Views
10526 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
User Interface
How to retrieve the size of a file being uploaded using a!fileUploadField() sail
abhinavg
over 9 years ago
How to retrieve the size of a file being uploaded using a!fileUploadField() sail component on sail form and restricts the user to upload a file larger than a certain limit.
Is it correct that document(ri!file, "size") will work only when form is being submitted as document being uploaded is being saved on Appian DMS and not before if sail form is not being submitted
Attached a sail form snippet, need to capture the size being circle on form
Thanks !
OriginalPostID-141769
OriginalPostID-141769
Discussion posts and replies are publicly visible
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
@Abhi: i think you might find Eduardo's suggestion of post-form validation to work rather well - in my case, when validation fails after submission, the gateway loops through a delete document node and the failed document is removed right away, then it loops straight back into the form where I display a SAIL-style validation message. To the user, it seems as if they never left the form and that the "upload" button just failed.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
srinivasulup
Certified Lead Developer
over 9 years ago
@Abhinavg: If I understood your requirement clearly the below code can help you identify the file size before you save that to appian.
saveInto:{
a!save(local!FileSize,(a!fileUploadField(target:targetfolder,value:ri!fileToUpload,saveInto:ri!fileToUpload).uploadedDocumentSize))
}
use this local!FileSize variable in validation attribute to validate accordingly
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kumaraveln
over 9 years ago
Thanks for sharing Srinivas. This would help in lot of validation for us.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kumaraveln
over 9 years ago
@Srinivas: Is there any other property that we can get in this way before submitting the form. Like documentId, documentName .. I tried few things like '.id', '.documentId', '.uploadedId', '.uploadedDocumentId' ..
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
@kumar: basically the only meaningful properties we can extract using this trick are size (abbreviated), and document name. I believe the property to use for name is "uploadedDocumentName", but you can check all the properties available by placing it in a text field, like this:
a!textField( readOnly: true(), value: a!fileUploadField( value: local!uploadedDocument ) )
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kumaraveln
over 9 years ago
@mschmitt: Checked it. You are right about 'uploadedDocumentName' property. Although the properties are limited, it was really helpful to know this. Especially, we need to display the actual file name of uploaded document in a read only grid right after user uploads. Till now we had to take the user out of screen and come back inside to achieve this. This is great .. Thanks for sharing ..
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kumaraveln
over 9 years ago
Also to mention, lot of people are looking for a way to validate minimum / max file upload size right after uploading .. This is a good workaround ..
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
I mainly use this to validate proper extension, as i've had requirements that certain file types not be allowed. I should note that this is not "officially" supported functionality, as in, there is no guarantee that the property names won't change in between appian versions, among other things. As such, I strongly suggest that you create external rules to handle taking the temporary document and extracting the name - that way if something ever changes, you only need to update your hanler rule(s) instead of any forms that used the literal property names.
Also just be cautious about using this for just-uploaded files in a grid; this makes it possible but at the same time, you're still going to be dealing with an array of "temporary" document IDs that don't become permanent ones until submit time. I'd strongly recommend continuing to submit the form between uploads, unless you have strong reasons not to.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kumaraveln
over 9 years ago
That's a good suggestion. Thanks ..
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
srinivasulup
Certified Lead Developer
over 9 years ago
@mschmitt: You are right there's no guarantee that the property names won't change in future versions.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
<