[mod_python] Re: Mike's psp upload

sandip more sandipm at talentica.com
Wed Jun 14 04:55:30 EDT 2006



----- Original Message ----- 
From: "Mike Looijmans" <nlv11281 at natlab.research.philips.com>
To: "sandip more" <sandipm at talentica.com>
Cc: <mod_python at modpython.org>
Sent: Tuesday, June 13, 2006 7:27 PM
Subject: Re: [mod_python] Re: Mike's psp upload


> The default behaviour of FieldStorage is to place the uploaded file in 
> some temp location. By providing the callback, you can prevent the file 
> being stored twice (once on temp, once on the final location). This allows 
> uploading files of many gigabytes without consuming diskspace or memory.
>
> Note that by doing:
>    filedata = afile.file.read()
> you read the entire file into system memory. If a user sends you a 1GB 
> file, your server is likely to "die" there. Use one of the
> shutil.copyfile functions to copy the file to where you want, without 
> (potentially) consuming megabytes of memory.

Thanks Mike for explaination, I got the point. but i didn't got the callback 
function's implementation..
can you give me some link to it?

and for memory thing, I am not clear about role of apache in this.
I think Apache should handle basic http request protocol.
it should store data in some file on disc rather than in-memory and
then should give mod_python handler a pointer to that file location.?
because anyway in the case of multiple requests, apache might fall short of 
memory
and might crash? please can you clear my doubts.

sandip




>
>
> Mike Looijmans
> Philips Natlab / Topic Automation
>
>
> sandip more wrote:
>> hello all,
>>  I am also trying to implement file upload functionality with psp. I 
>> didn't get the use of callback function.
>> I am able to access the data of uploaded file with following code.
>>  frm = util.FieldStorage(req)
>> for afile in frm.getlist('UploadFile'):
>>     filedata = afile.file.read()
>>     #write filedata to some file in local directory with name 
>> afile.filename.
>>  can someone explain me..what is the need of this callback function? also 
>> how it works?
>>  Thanks
>> Sandip
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
> 



More information about the Mod_python mailing list