[Zope] Get files from the disk

Herve Coatanhay herve@virtual-net.fr
Wed, 08 Aug 2001 12:42:37 +0200


ruben wrote:

> Hello.
> 
> I have a new and big problem
> I'm migrating of IIS to Zope, but now in a directory of de old web I have a
> lot of images (over 8.000).
> 
> Do you now how can I?
> 
> 1- Put all this files to zope at the same time. (Not one to one)
> 
> or
> 
> 2- Do that Zope read directly from the hard disk. I would prefer this
> option.
> 
> 
> Thanks.

For 2 : use an external method in Python that returns an image:

def get_external_image(self,filename,REQUEST,RESPONSE):
     if not os.path.exists(filename):
        return ""

     fptr=open(filename, "rb")
     data=fptr.read()
     size=len(data)
     fptr.close()

     RESPONSE.setHeader("Content-Type", "image/png")
     RESPONSE.setHeader("Content-Length",size)

     return data

for PNG images


--
Hervé Coatanhay