I'm not sure how you might be able to process the file *while* it is
uploading (i.e., process the bytes as they are received by the server), but
if you can wait until the file is fully uploaded, you can access the
uploaded file as a Python cgi.FieldStorage object:
def upload():
if request.vars.myfile:
video = encode_video(request.vars.myfile.file)
[do something with video]
form = SQLFORM.factory(Field('myfile', 'upload', uploadfolder=
'/path/to/upload')).process()
return dict(form=form)
Upon upload, request.vars.myfile will be a cgi.FieldStorage object, and the
open file object will be in request.vars.myfile.file. Note, if the encoding
takes a while, you might want to pass it off to a task queue rather than
handle it in the controller.
Anthony
On Monday, June 4, 2012 4:23:55 AM UTC-4, Charles Tang wrote:
>
> I am using a sqlform to upload a video file and want to encoding the video
> file while uploading. But I noticed that the upload file is not saved to
> uploads directory utill it is completely uploaded. Is there a temporary
> file and how can I access it ?Thanks.
>