[Zope] Help on mass import of images

Seb Bacon seb@jamkit.com
Thu, 6 Dec 2001 12:39:05 -0000


It looks to me like you're trying to upload a string: "TheImage", not
data.

  self._getOb(id).updata_data(TheImage,content_type='image/gif')

is possibly what you want.  It depends what import_pictures does...

Why not FTP your images into the system?  You'd have to create a custom
ftp PUT handler (search for hookable put).  Then you could just drag and
drop your images into zope.

seb

----- Original Message -----
From: Sven Rudolph <rudolph@medical-tribune.de>
To: <zope@zope.org>
Sent: Thursday, December 06, 2001 12:05 PM
Subject: [Zope] Help on mass import of images


> Hello,
>
> I have a problem to import images automatically. All in all I have
2000 images to import into zope, and I tried the following method:
>
> I created an external method "import_images.py":
> >>>>>>>>>>>>
> from OFS.Image import Image
>
> def import_pictures(self):
>
>  id='picture1'
>  handle=Image(id,'','',content_type='image/gif')
>  self._setObject(id,handle)
>  self._getOb(id).updata_data('''TheImage''',content_type='image/gif')
>
>  id='picture2'
>  handle=Image(id,'','',content_type='image/gif')
>  self._setObject(id,handle)
>  self._getOb(id).updata_data('''TheImage''',content_type='image/gif')
>
> .....and so on
> <<<<<<<<<<<<<<<<<<
> I copied it to <zope-path>/Extensions, created an "External
Method"-object in my image folder and then clicked on the "Test"-tab of
my external method. I got two different types of errors, depending on
the encoding of my image-data.
> If the string "TheImage", which contains the image data, was base64
encoded, an image object was created, but the image data was broken
(view tab of the image object).
> If the string "TheImage" contained the pure binary data of the image
(starting with GIF89a...), I got a syntax error from the parser when I
tried to create the external method, as I expected.
>
> I also tried to upload the image data with
>  self._getOb(id).manage_upload('''TheImage''')
> but with the same results.
>
> Can anybody help me?
>
>
> P.S. By the way: the script "import_images.py" is automatically
created by a perl script.
>
> Thanks in advance
>
> Sven