Am Donnerstag, den 24.11.2005, 11:49 -0800 schrieb Michael Dexter:
> Hello,
> 
> I apologize if this is a FAQ, I could not find the answer.
> 
> I would like to put a 120MB file into ZODB and it is constantly failing.
> 
> TTW insert file fails but works on smaller fails.
> 
> WebDAV fails but works on smaller files.
> 
> Plus FTP fails having activate it as a last resort.
> 
> My environment is FreeBSD 6 with current Zope, Python 2.3.x and a 
> /tmp directory of 256MB... I noticed once that this could cause this 
> failure.
> 
> Any suggestions?
> 
> I do have the file on the OS's filesystem but I see that the object 
> "import" only applies to ZODB-ready files.

You could always:

zopectl debug

filedata=open("fileystempath/to/your/file")

app.path_in_zope.manage_addFile("fileid",filedata)

import transaction
transaction.get().commit()

Or use the uploader in the attachment (lets see if
it goes thru the list) like this:

./bin/zopectl run fileimport.py bigfile /path/in/zope/

Greats
Tino


#!zopectl
# Fileimporter for Zope by Tino Wildenhain

import sys,time,os

class ProgressFile(file):
	"Class renders progressbar on read"
	def __init__(self,filename):
		"this file is read only"

		file.__init__(self,filename,'rb')
		self.seek(0,2)
		self._size=self.tell()
		self._start=time.time()
		self.headers={'content-type':'application/octet_stream'}
		
	def read(self,chunksize=8192):
		"zope image.py reads in chunks but from end to start"

	        b=file.read(self,chunksize)
		s=self.tell()
		t=time.time()-self._start
		sys.stdout.write("\r%5.1f%% (%8.1f kb/s) |%-80s" % (100-100*s/self._size,s/t/1024,"#"*int(80-80*s/self._size)))
		sys.stdout.flush()
		
	def close(self):
		file.close(self)
		t=time.time()-self._start
		sys.stdout.write("\n\n%d bytes in %d secs = %8.1f kb/s\n\n" % (self._size,t,self._size/t/1024))
		sys.stdout.flush()
		
def importfile(filesystempath,zopepath):
	"""resulting ID in zope is either the file
	   name of the target path or the filename
	   of the source"""

	filedata=ProgressFile(filesystempath)
	zdir,zfile=os.path.split(zopepath)
	if not zfile:
	    zfile=os.path.split(filesystempath)[1]
	target=app.restrictedTraverse(zdir)
	target.manage_addFile(zfile,file=filedata,content_type='application/octet-stream')
	import transaction
	transaction.get().commit()
	filedata.close()

if __name__=='__main__':
	try:
		source,target=sys.argv[1:3]
	except IndexError:
		sys.stderr.write("%s uploadfile zopepath\n")
		sys.stderr.flush()
	
	importfile(source,target)
	
_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to