Uploaded Files (form POST): FormUploadedFile

The values of a form parameter that you get from the request object (via getForm() or getParameter() ) can be one of three things: a plain string, a list (of strings) or a FormUploadedFile object (when the user has uploaded a file). Import the class like this:

from snakeserver.webform import FormUploadedFile, FormFileUploadError

The following attributes are defined on that object:

attribute description
name form field name
file file object to read file contents from
filename filename (the base name; i.e. without any path)
mimeType mime type of the uploaded file (such as 'image/gif')
disposition disposition (such as 'form-data')
dispositionOptions disposition options (dict)
typeOptions type options (dict)

Don't forget the maxPOSTsize attribute of the Request object. It is 200000 (200 Kb) by default, if you need bigger POSTs, increase this value (request.setMaxPOSTsize() ) before calling Request.getForm(). If a form upload is bigger than maxPOSTsize, you will get a snakeserver.webform.FormFileUploadError exception .

Snakelets manual - Back to index