Note
This class is accessible using both hou.WebServerUploadedFile
and
hou.webServer.UploadedFile
, but hou.webServer.UploadedFile
is
preferable.
Methods ¶
name()
→ str
Returns the name of the file that was uploaded. Note that this is different from the POST variable name; the POST variable name is the key in the /hom/hou/webServer/Request.html#files dict.
size()
Returns the size of the file that was uploaded.
isInMemory()
→ bool
Returns whether the uploaded file is currently stored in memory, or if it is too large and was streamed to a temporary file on disk. See hou.webServer.run to change the thresholds for what is considered a large file upload.
temporaryFilePath()
→ str
If isInMemory returns False
,
returns the path to the uploaded file that was streamed to disk. Otherwise
returns an empty string.
Note that if an uploaded file was saved to disk it is automatically deleted after the response is sent.
saveToDisk()
Force a in-memory file to be saved to a temporary file on disk.
If the file was already saved to a temporary file, calling this method has no effect.
read(max_size=-1)
→ str
for Python 2, bytes
for Python 3
Read up to max_size
bytes of the uploaded file and return the bytes
as a bytes
object in Python 3 and a str
object in Python 2 (see
HOM binary data support for more information). This
method handles the cases where the file’s contents are stored in memory and
when they are in a temporary file. If max_size
is negative this method
returns the rest of the data in the file, but be careful not to load very
large file uploads into memory.