Helper class that opens and saves StoredFile objects The default implementation stores files in the settings.CAMELOT_MEDIA_ROOT directory. The storage object should only be used within the model thread, as all of it’s methods might block.
The methods of this class don’t verify if they are called on the model thread, because these classes can be used server side or in a non-gui script as well.
Verify if the storage is available
Returns: | True if the storage is available, False otherwise |
---|
Check the file pointed to by local_path into the storage, and return a StoredFile
Parameters: |
|
---|
is given, the filename from the local path will be taken.
The stored file is not guaranteed to have the filename asked, since the storage might not support this filename, or another file might be named like that. In each case the storage will choose the filename.
Check the datastream in as a file into the storage
Parameters: |
|
---|---|
Returns: | a StoredFile |
This method can also be used in combination with the StringIO module:
import StringIO
stream = StringIO.StringIO()
# write everything to the stream
stream.write( 'bla bla bla' )
# prepare the stream for reading
stream.seek( 0 )
stored_file = storage.checkin_stream( 'document', '.txt', stream )
Check the file pointed to by the local_path out of the storage and return a local filesystem path where the file can be opened
Check the file stored_file out of the storage as a datastream
Returns: | a file object |
---|
Lists all files with a given prefix and or suffix available in this storage
Returns: | a iterator of StoredFile objects |
---|
Helper class for the File field type. Stored file objects can be used within the GUI thread, as none of its methods should block.
Helper class for the Image field type Class linking an image and the location and filename where the image is stored