Continuing the discussion from @mathieubossaert's Xlsform "spare parts" : Basic authentication of the enumerator:
While thinking about the file
question type and not being able to restrict on file size [1] or type via parameters I wondered if a simple constraint would be able to prevent files by their extension. (allowing that some bad actors may rename their file to an allowed extension so this should be used with appropriate caution)
This form offers two ways to restrict file upload by extension, either (first) with an excel table of permissible extensions, and some excel formulae to build the label / constraint / message, or (second, slightly more elegant but can break with certain filenames/extensions) with a choice list of permitted extensions that are joined and then used with a contains
against the attachment extension substring. Both translate the extension to upper case so the lists only need the upper case, not upper and lower (or mixed!)
Both work in Enketo & Collect. (with a caveat that file extensions over 4 characters won't work for option 2)
File question type isn't supported in webforms yet.
I did notice that in Collect the picked file extension != the attached file extension in all cases, eg a foo.mbtiles
file that is listed as Type: 'BIN file' in the picker is attached as timestamp.bin
not timestamp.mbtiles
The form:
ODK_Example_file_extensions.xlsx (116.0 KB)
Also note that in Enketo the file picker will use 'custom files' and might need to be changed to 'all files' to be able to select the desired file type. Discussed here
I don't know what happens if you attach a huge file in Collect and attempt to send, will it tie up bandwidth and eventually it'll send and be rejected by Central, or will Collect refuse to attach/send files above the Central configured limit (100MB by default)? - I was able to attach a 150MB file to my form, but I haven't tried to send it ↩︎