Storing files on the file system using FileSystemStorage
Populating your ZODB with large files can inflate it into a huge size in no time. The ZODB also keeps track of each change to a file, which revisions the whole object. Repacking your Data.fs file or even performing regular backups once your ZODB gets too large can be a cumbersome task as well.
Luckily, there is an excellent product called FileSystemStorage that allows you to store files added to your Plone site onto your file system. FileSystemStorage works transparently in the background and allows users in Plone to add and manage content stored on the file system no differently than the standard Plone way. All it takes is a few lines of additional code added to a custom content type to store files on the file system and you are off and running.
Once you have installed and configured FileSystemStorage (the README.txt that comes with FileSystemStorage is very well documented) you will need to create, or modify your custom content type. When this new content type is then added in Plone, it knows to store the content on the file system and not in the ZODB.
In this example, I created a new custom content type called
MyFile (via ArchGenXML), which was derived from ATFile.
The following lines (courtesy of Andreas Jung) were then added to my python file
MyFile.py.
def updateSchema(schema): field = schema['file'] field.storage = FileSystemStorage() field.registerLayer('storage',field.storage) class MyFile(ATFile): ..... ..... schema = MyFile_schema updateSchema(schema) .....
Once you add the code, restart Zope and then install or reinstall your custom content type. Now when content is added via your custom content type, it will be stored on the file system instead of the ZODB.
