RE: [Zope] Getting image
I guess I'm confused. I can't get to the actual jpeg image? Here's what I'm trying to do. I want to create a form to upload data. This data can be off any type. The data is stored in an ODBC database table along with it's mime type. So, on the upload action form, I need to 1) get the mime type and 2) get the actual data. Another part of the site mails off these items as attachments. I've heard that the mime type should be uploaded along with the data, I just don't know how to get to it.
-----Original Message----- From: Michel Pelletier [mailto:michel@digicool.com] Sent: Wednesday, March 15, 2000 12:54 PM To: Daniel.Weber@SEMATECH.Org Cc: zope@zope.org Subject: Re: [Zope] Getting image
Daniel.Weber@SEMATECH.Org wrote:
I uploaded an image and want to attach it to an email
message using <dtml-mime>.
How do I get the actual image? <dtml-var image> gives me the <img > tag. "image.content_type" gives me content type properly, but I don't know the property name for the actual data.
Hmm.. unfortunatly there is no good way to do this from DTML except to use manage_FTPget(). Yuk. This lack will be fixed in the near future when we re-do alot of the Zope interfaces. Currently we are in the middle of documenting all of the existing interfaces which obviously must come first.
-Michel
Daniel.Weber@SEMATECH.Org wrote:
I guess I'm confused. I can't get to the actual jpeg image?
Not directly from DTML. You need to use a method on the Image object. manage_FTPget().
Here's what I'm trying to do. I want to create a form to upload data. This data can be off any type. The data is stored in an ODBC database table along with it's mime type. So, on the upload action form, I need to 1) get the mime type and 2) get the actual data.
This is different from the first question that you asked. In this case, when your form uploads the file contents, ZPublisher will marshal that into a StringIO object (which acts just like a python file object). In this case you can just do: <dtml-var "REQUEST['name_of_form_element_that_is_the_file'].read()"> and get the 'contents' of the file.
Another part of the site mails off these items as attachments. I've heard that the mime type should be uploaded along with the data, I just don't know how to get to it.
In this case, your taking about a Zope 'Image' object, _not_ a standard file object like you get when you upload data. For this you need manage_FTPget(). -Michel
I guess I'm confused. I can't get to the actual jpeg image?
Not directly from DTML. You need to use a method on the Image object. manage_FTPget().
Actually you can get the image data as <dtml-var "my_image.data"> where "my_image" is the name of your image object. The following DTML will return the actual image to a browser (tested): <dtml-call "REQUEST.set('Content-Type', my_image.content_type)"><dtml-var "my_image.data"> It is crucial that the DTML method contain no extra whitespace, though, as this will be interpreted as part of the image data. --jfarr
participants (3)
-
Daniel.Weber@SEMATECH.Org -
Jonothan Farr -
Michel Pelletier