how to download big files using zope?
Hi! I have some big files (about 500 MB) in the filesystem on the server and want to make them downloadable. I could do something like this, but it loads the file into memory: <code> def manage_download(self, REQUEST): myfile = open('myfile.bin', 'rb') filestring = myfile.read() myfile.close() REQUEST.RESPONSE.setHeader('Content-type', 'application/data') REQUEST.RESPONSE.setHeader('Content-Disposition', 'inline;filename=myfile.bin') return filestring </code> Is there a way to just pass the file through? Without loading it in a string or in the ZODB? Any hints are welcome. TIA, Yuppie
Google for ExtFile. -- Andy McKay www.agmweb.ca ----- Original Message ----- From: "Yuppie" <schubbe@web.de> To: <zope@zope.org> Sent: Saturday, October 05, 2002 10:31 PM Subject: [Zope] how to download big files using zope?
Hi!
I have some big files (about 500 MB) in the filesystem on the server and want to make them downloadable.
I could do something like this, but it loads the file into memory:
<code> def manage_download(self, REQUEST): myfile = open('myfile.bin', 'rb') filestring = myfile.read() myfile.close() REQUEST.RESPONSE.setHeader('Content-type', 'application/data') REQUEST.RESPONSE.setHeader('Content-Disposition', 'inline;filename=myfile.bin') return filestring </code>
Is there a way to just pass the file through? Without loading it in a string or in the ZODB?
Any hints are welcome.
TIA, Yuppie
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Andy McKay wrote:
Google for ExtFile. -- Andy McKay www.agmweb.ca
----- Original Message -----
Is there a way to just pass the file through? Without loading it in a string or in the ZODB?
Thanks! But I had a look at the source of ExtFile: It copies the file into StringIO(). That means it *does* load the complete file into memory before you can download it. Any other hints? Yuppie
At 08:44 2002-10-06 +0200, Yuppie said:
Andy McKay wrote:
Google for ExtFile. -- Andy McKay www.agmweb.ca ----- Original Message -----
Is there a way to just pass the file through? Without loading it in a string or in the ZODB?
Thanks! But I had a look at the source of ExtFile:
It copies the file into StringIO(). That means it *does* load the complete file into memory before you can download it.
Any other hints? Yuppie
Hi Yuppie, I've made a hack of the LocalFS product that can stream objects from the filesystem instead of copy through StringIO. I have put it on zope.org: http://www.zope.org/Members/johanc/StreamingFS/StreamingFS.zip Most other products I've looked at does this copy operation. Regards, Johan Carlsson -- Torped Strategi och Kommunikation AB Johan Carlsson johanc@torped.se Mail: Birkagatan 9 SE-113 36 Stockholm Sweden Visit: Västmannagatan 67, Stockholm, Sweden Phone +46-(0)8-32 31 23 Fax +46-(0)8-32 31 83 Mobil +46-(0)70-558 25 24 http://www.torped.se http://www.easypublisher.com
Johan Carlsson [Torped] wrote:
I've made a hack of the LocalFS product that can stream objects from the filesystem instead of copy through StringIO.
I have put it on zope.org: http://www.zope.org/Members/johanc/StreamingFS/StreamingFS.zip
Most other products I've looked at does this copy operation.
Many thanks! That seems to be exactly what I've been looking for. Yuppie
Johan Carlsson [Torped] wrote:
I've made a hack of the LocalFS product that can stream objects from the filesystem instead of copy through StringIO.
Perhaps you could feed these changes back into the LocalFS project on SourceForge? cheers, Chris
Really? Well thats a problem, didnt realise it did that. LocalFS does the same thing. Have you tried 1.0 of LocalFS it might have fixed that. -- Andy McKay www.agmweb.ca ----- Original Message ----- From: "Yuppie" <schubbe@web.de> To: "Andy McKay" <andy@agmweb.ca>; <zope@zope.org> Sent: Saturday, October 05, 2002 11:44 PM Subject: Re: [Zope] how to download big files using zope?
Andy McKay wrote:
Google for ExtFile. -- Andy McKay www.agmweb.ca
----- Original Message -----
Is there a way to just pass the file through? Without loading it in a string or in the ZODB?
Thanks! But I had a look at the source of ExtFile:
It copies the file into StringIO(). That means it *does* load the complete file into memory before you can download it.
Any other hints?
Yuppie
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
FWIW, I have a patch for ExtFile that does away with StringIO. http://www.zope.org/Members/shh/Patches/ Stefan --On Sonntag, 06. Oktober 2002 08:44 +0200 Yuppie <schubbe@web.de> wrote:
Andy McKay wrote:
Google for ExtFile. -- Andy McKay www.agmweb.ca
----- Original Message -----
Is there a way to just pass the file through? Without loading it in a string or in the ZODB?
Thanks! But I had a look at the source of ExtFile:
It copies the file into StringIO(). That means it *does* load the complete file into memory before you can download it.
Any other hints?
Yuppie
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Those who write software only for pay should go hurt some other field. /Erik Naggum/
participants (5)
-
Andy McKay -
Chris Withers -
Johan Carlsson [Torped] -
Stefan H. Holek -
Yuppie