I currently design a custom form with a button that calls a regular file picker. In my scenario, end users shall only be able to upload certain datatypes, like txt and xml. As the affected users group does not have any edit rights for items, I have to upload the Files to the Vault and link them later to the correct items by a Server Method. As this approach directly throws files into the Vault, I want to ensure that only the right files can go through.
What´s the best way to add restrictions to the file picker?
var vlt = aras.vault;
if (fileObject.size > 1000 || fileObject.type != "text/xml" )
return alert("This file can´t be right")
var fileItem = inn.newItem("File","add");
fileItem = fileItem.apply();
var fileId = fileItem.getID();
// do something with the file
I have noticed, that the fileObject contains the mime type, file size and other file properties that I can use for a later filtering. It´s even possible to read the hex file signature, which maybe helps to prevent faked files. But I wonder if I can directly pass a filter to the file picker, so users can only select certain file types from the start. This way my lnnovator would not get in touch with invalid fileObjects at all.
Thanks for sharing your ideas!