[Zope] Storing files externally

Kaleissin taliesin@nvg.org
Sat, 18 Dec 1999 00:36:11 +0000


* Alexander Limi (alexander@limi.net) [991218 01:22]:
> > Hi Alex, I just use a simple external method for this purpose.  I have a
> > form that has a file input box called "file".  The form posts to this
> > external method using method="post" and enctype="multipart/form-data".
> >
> > It's a small function, so I'll just post the code here:
> >
> > def processFile(self, file, REQUEST=None, RESPONSE=None):
> >
> >     buffer = file.readlines()
> >
> >     outfile = open('%s/new_data.txt' % ATTACHMENTS_HOME, 'w')
/snippage/
> 
> This _almost_ does the trick. Text files work fine, but GIFs do not. I suspect
> it may be because the buffer processing adds something to the data - in any
> case the file is garbled in the other end. The size of the file is not
> correct, [..] , ie. it ends up being 27 bytes larger than the original.

Tried treating the file as binary?
outfile = open('%s/new_data.txt' % ATTACHMENTS_HOME, 'wb')
                                                       ^

tal.