file_store module
Requirements:
FILE_STORE_DIR setting - main file store directory * must be a subdirectory of MEDIA_ROOT * must be writeable by the Django server Example: FILE_STORE_DIR = ‘files’
LRU file cache
Bases: django.db.models.base.Model
Represents data files on disk.
Bases: django.core.exceptions.ObjectDoesNotExist
Bases: django.core.exceptions.MultipleObjectsReturned
Delete datafile if it exists on disk.
Returns: | bool – True if deletion succeeded, False otherwise. |
---|
type of the file
Compute the absolute path to the data file.
Returns: | str – the absolute path to the data file or None if the file |
---|
does not exist on disk.
Return extension of the file on disk or from the source.
Returns: | str – file extension that begins with a period. |
---|
Open data file.
Returns: | file object – or None if failed to open data file. |
---|
Return the size of the file in bytes.
Parameters: | report_symlinks (bool.) – report the size of symlinked files or not. |
---|---|
Returns: | int – file size. Zero if the file is: - not local - a symlink and report_symlinks=False |
Retrieve the type of the datafile.
Returns: | str – type of the datafile. |
---|
Return the full URL (including hostname) for the datafile.
Returns: | str – local URL or source if it’s a remote file |
---|
Check if the datafile can be used as a file object.
Returns: | bool – True if the datafile can be used as a file object, False otherwise. |
---|
Check if the data file is a symlink.
Returns: | True if the datafile is a symlink, False if not. |
---|
Change name of the data file. New name may not be the same as the requested name in case of conflict with an existing file.
Parameters: | name (str.) – new data file name. |
---|---|
Returns: | str – new name if renaming succeeded, None otherwise. |
Assign the type of the datafile. Only existing types allowed as arguments.
Parameters: | filetype (str.) – requested file type. |
---|---|
Returns: | True if success, False if failure. |
optional subdirectory inside the file store that contains the files of a
source URL or absolute file system path
Create a symlink to the file pointed by source. Does not check that the source is an absolute file system path.
Returns: | bool – True if success, False if failure. |
---|
unique ID
Bases: django.core.files.storage.FileSystemStorage
Custom file system storage class with support for symlinked files.
Construct relative file system path for new file store files relative to FILE_STORE_BASE_DIR. Based on http://michaelandrews.typepad.com/the_technical_times/2009/10/creating-a-hashed-directory-structure.html
Parameters: |
|
---|---|
Returns: | str – if success, None if failure. |
Return file extension given its file system path.
Returns: | str – File extension preceeded by a period. |
---|
Return file extension of the file specified by UUID.
Parameters: | uuid (str.) – UUID of a FileStoreItem. |
---|---|
Returns: | str – extension of the data file. |
Open file given its name.
Parameters: | file_name (str.) – name of the file. |
---|---|
Returns: | file object – or None if failed to open file. |
Return size of the file specified by UUID.
Parameters: |
|
---|---|
Returns: | int – size of the file on disk. |
Return the absolute path to the file store temp dir.
Returns: | str – absolute path to the file store temp dir. |
---|
Check if this FileStoreItem can be used as a file object
Parameters: | uuid (str.) – UUID of a FileStoreItem |
---|---|
Returns: | bool – True if yes, False if no. |
Check if FileStoreItem instance is referenced in the cache.
Parameters: | uuid (str.) – UUID of a FileStoreItem. |
---|
Bases: exceptions.StandardError
Exception raised for download errors
This file contains tests for file_store.models and file_store.tasks
Bases: django.test.testcases.SimpleTestCase
FileStoreItemManager methods test.
Test that empty map doesn’t affect creating new FileStoreItem instances.
Test translation from URL to file system path when creating a new instance.
Bases: django.test.testcases.SimpleTestCase
FileStoreItem methods test.
Check that the correct file extension is returned.
Check that the correct file type is returned
Check if the source URL is returned for files that have not been imported
Check that a file type is set automatically
Check that an unknown file type is not set
Check that a valid file type is set correctly
Bases: django.test.testcases.SimpleTestCase
File store module functions test.
Check that the file store path contains share name and file name.
Check if the parentheses are replaced with underscores in the file name
Decorator version of the test_get_file_obejct()
Check that the file store temp dir is reported correctly.