[Zope] LocalFS - large files / broken connections

David Siedband david at calteg.org
Fri Aug 15 21:28:22 EDT 2003


I'm using LocalFS as a repository for uploading files.  Many files are 
relatively large, perhaps in the 10-20 Meg range.

Is the file cached by Zope and then written to the filesystem all at 
once or is it written to the filesystem in incrementally?  From the 
product code below, it looks like it it writing directly to the path 
location...

What happens if someone is uploading a file and their net connection is 
broken?  How would this be handled?  Could this result in a partial 
file being cached somewhere that needs to be purged or perhaps a write 
process that needs to be killed off?

Thanks,
--
David

Here's what I think is the relevant code from the product...

     def manage_upload(self, file, id='', action='manage_workspace', 
REQUEST=None):
         """Upload a file to the local file system. The 'file' parameter
         is a FileUpload instance representing the uploaded file."""
         if hasattr(file,'filename'):
             filename=file.filename
         else:
             filename=file.name
         if not id:
             if '/' in filename:
                 id=filename[string.rfind(filename,'/')+1:]
             elif '\\' in filename:
                 id=filename[string.rfind(filename,'\\')+1:]
             elif ':' in filename:
                 id=filename[string.rfind(filename,':')+1:]
             else:
                 id=filename

         try: self._checkId(id,1)
         except: raise 'Upload Error', MessageDialog(
                       title='Invalid Id',
                       message=sys.exc_value,
                       action ='manage_main')
         path = self._getpath(id)
         if os.path.exists(path): self.manage_overwrite(file, path, 
REQUEST)
         else: self._write_file(file, path)

         if REQUEST: return MessageDialog(
                     title='Success!',
                     message='Your file has been uploaded.',
                     action=action)




More information about the Zope mailing list