In gluon main there is this code:
request.body = copystream_progress(request) ### stores request body
if (request.body and request.env.request_method in ('POST', 'PUT',
'BOTH')):
dpost =
cgi.FieldStorage(fp=request.body,environ=environ,keep_blank_values=1)
request.body.seek(0)
- request.body is a temporary copy of input stream (contains the multipart
form, which may have files in it)
- cgi.FieldStorage(fp=request.body) parses the request stream and return a
dictionary of FieldStorage objects (including files that may be in there)
Perhaps this helps.
On Monday, 4 June 2012 23:55:23 UTC-5, Charles Tang wrote:
>
> I have test request.vars.file_field.file, it can only be accesssed after
> the whole file is uploaded.Should I do it at a lower level?
>
> On Tuesday, June 5, 2012 11:41:28 AM UTC+8, Charles Tang wrote:
>>
>> Can the request.vars.file_fileid.file be accessed before the video is
>> completely uploaded?
>>
>> On Monday, June 4, 2012 11:36:35 PM UTC+8, Massimo Di Pierro wrote:
>>>
>>> The file is in request.vars.file_field.file which is a read-only stream.
>>> You can shutil.copyfile it to a temporary folder.
>>>
>>> On Friday, 14 January 2011 18:56:41 UTC-6, Thomas Dall'Agnese wrote:
>>>>
>>>> Dear community,
>>>>
>>>> I have a form with an upload field that I use to upload a text file,
>>>> parse information from this file and store this information into the
>>>> database, but not the file itself.
>>>>
>>>> The form is for example defined by:
>>>> form = FORM(INPUT(_name='file_field', _type = 'file', requires =
>>>> IS_NOT_EMPTY()),
>>>> INPUT(_type='submit'))
>>>>
>>>> I can access the file content with request.vars.file_field.file.read()
>>>> but this function does not detect the file encoding and open all my
>>>> file as utf-8.
>>>> So instead I would like to use codecs.open(xxx, "r", charset) to
>>>> define the charset (utf-8, iso-8859-1, ...).
>>>> However, as I don't store the file, I can't find the file in the
>>>> uploads/ directory.
>>>> How can I find the temporary file path if there is any?
>>>>
>>>> Or do you have any suggestion to read the uploaded file with the right
>>>> encoding (without chardet)?
>>>>
>>>> Best regards,
>>>>
>>>> $p00ky
>>>
>>>