Codebase list sugar-read-activity / c1b27e2
Save the mimetype in the metadata when download a shared file Some mime files, like epub, are not recognized if the extension is not set. We need use the suggested_name extension to save the file, and save the mimetype in the metadata. Signed-off-by: Gonzalo Odiard <godiard@sugarlabs.org> Gonzalo Odiard 10 years ago
1 changed file(s) with 9 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
802802
803803 del self.unused_download_tubes
804804
805 # Use the suggested file, the mime is not recognized if the extension
806 # is wrong in some cases (epub)
807 temp_dir = os.path.dirname(tempfile)
808 new_name = os.path.join(temp_dir, suggested_name)
809 os.rename(tempfile, new_name)
810 tempfile = new_name
811
805812 _logger.debug("Saving file %s to datastore...", tempfile)
813 mimetype = Gio.content_type_guess(tempfile, None)[0]
814 self._jobject.metadata['mime_type'] = mimetype
806815 self._jobject.file_path = tempfile
807816 datastore.write(self._jobject)
808817