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 >> >>