The falcon-apache2 module allow to retreive and manage uploaded files through a class called Uploaded. Each field of a file upload enable form is turned into an Uploaded instance in the coresponding post entry of the Request entity.
In example, this form:
<form action="receiver.ftd" method="POST" enctype="multipart/form-data" accept-charset="utf-8"> <p>Form field: <input type="text" name="Afield" value="aaaa"/> <p>Input file: <input type="file" name="TheFile"/> <p><input type="submit" name="sub_btn" value="Send"/> </form>
will cause the Request.posts dictionary to contain a string entry for the "Afield" key, and an Uploaded instance for TheFile. A typical inspect() result on the Request.posts dictionary may be like the following:
Dict[2]{ "Afield" => "aaaa" "TheFile" => Object of class Uploaded { data => Nil error => Nil filename => "kusamakura.pdf" mimeType => "application/x-filler" open => Ext. Function Uploaded.open read => Ext. Function Uploaded.read size => int(472396) storage => "/tmp/8sO5pvU6ZoxEY1Qn" store => Ext. Function Uploaded.store } "sub_btn" => "Send" }
Note: Notice the accept-charset parameter of the form tag. As MIME type doesn't specify an encoding standard for multipart data, the falcon-apache2 module assumes that all the fields in multipart posted forms (except the file entries) are encoded in utf-8. Please, use the accept-charset="utf-8" in every multipart form when sending data to Falcon modules.
The falcon.ini file, tipically placed in /etc/falcon.ini, contains some key that control the upload settings. Namely, they are:
The falcon-apache2 module can receive the uploaded files in two ways:
If a file is smaller than MaxMemUpload parameter set in configuration, it is directed to the Uploaded.data field and its whole contents are stored in a MemBuf.
If it's larger, it is stored in a temporary file whose complete path is written as a string in the Uploaded.storage property of the incoming data. To have every upload saved in a temporary file, set MaxMemUpload to zero, to have everything in memory without disk storage set MaxMemUpload to the same value as MaxUpload.
The Uploaded class has a set of functions that are useful to threat both upload modes the same way at script level, so to virtualize the way data is temporarily stored locally. They are namely:
Temporary files are destroyed when the script terminates, so they don't waste system resources and the script doesn't need to take care of their deletion.