[Zope] Uploading Image

saravanan annamalai saravanan annamalai" <saravanan_anna@rediffmail.com
4 Apr 2003 13:17:45 -0000


hi...
    ur code works perfectly well... I just made use of the 
manage_addImage method... ie the only diff...
thx a lot
sara

PS: here is the modified code

def main(self):
     fileName = 'pythonpowered.gif'
     #Directory on FSO that contains the image to upoload
     myDir='/home/saravan/testpython/'
     #Read file from directory (please try use 'r'  vs.'rb' to NOT 
read in binary mode)
     f = open(myDir+fileName, 'rb')
     data = f.read()
     f.close()
     del f
     #Set the folder (''testZopeFolder') in which I want upload 
the file (from the context of ExternalMethod)
     obj=self.restrictedTraverse('Files/')
     #File upload (please note to set the content-type property)
     obj.manage_addImage(fileName,data, 
content_type='image/gif')
     del data
     return None



On Thu, 03 Apr 2003 Maurizio Betti wrote :
>At 14.48 03/04/2003 +0000, you wrote:
>>Hi all,
>>    How can I upload an image through Python script(external 
>>method also ok) in zope, with out using any html form...
>>
>>   ie) I have a file in my servers folder.... Just I want to add 
>>this to zope... I dont have any html form to browse file....
>>
>>   hope somebody will help me
>>bi from saravanan annamalai
>
>Hy, I just solved this problem some days ago BUT for a text file 
>(but this is not problem in my opinion). The code for 
>ExternalMethod is:
>
>  #Load a file from Server FSO in Zope without using form
>def main(self, fileName):
>     #Directory on FSO that contains yhe image to upoload
>     myDir='C:\\temp\\'
>     #Read file from directory (please try use 'r'  vs.'rb' to 
>NOT read in binary mode)
>     f = open(myDir+fileName, 'rb')
>     data = f.read()
>     f.close()
>     del f
>     #Set the folder (''testZopeFolder') in which I want upload 
>the file (from the context of ExternalMethod)
>     obj=self.restrictedTraverse('testZopeFolder/')
>     #File upload (please note to set the content-type 
>property)
>     obj.manage_addFile('fileID',data, content_type=''set the 
>content-type...img/...')
>     del data
>     return true
>
>OK? Write me if you have some problems...
>
>Bye, Mau
>
>ps: a special thanks to Michele Zanotti!
>

_______________________________________________________________________
Odomos - the only  mosquito protection outside 4 walls -
Click here to know more!
http://r.rediff.com/r?http://clients.rediff.com/odomos/Odomos.htm&&odomos&&wn