Function | filechunks | Return an iterator which reads chunks of the given file. |
Function | copy_and_close | Copy from_file to to_file and close both. |
Function | sha1_from_path | Return the hexdigest SHA1 for the contents of the path. |
Function | guess_librarian_encoding | Return the appropriate encoding for the given filename and mimetype. |
It requires both arguments to be opened file-like objects. 'filechunks' trick is used reduce the buffers memory demanded when handling large files. It's suitable to copy contents from ILibraryFileAlias instances to the local filesystem. Both file_descriptors are closed before return.
Return the appropriate encoding for the given filename and mimetype.
Files with the following extensions will be served as 'Content-Encoding: gzip' and 'Content-Type: text/plain', which indicates to browsers that, after being unzipped, their contents can be rendered inline.
Parameters | filename | string containing the filename to be guessed; |
mimetype | string containing the stored mimetype; | |
Returns | a tuple containing the appropriate 'encoding' and 'mimetype' that should be used to serve the file. |