Commit 645a4ece authored by Sebastien Robin's avatar Sebastien Robin

allow to upload/download Files with unknown mime type

parent 48f86374
...@@ -86,6 +86,7 @@ class DownloadableMixin: ...@@ -86,6 +86,7 @@ class DownloadableMixin:
output_format = None output_format = None
if not format: if not format:
# Guess the format from original mimetype # Guess the format from original mimetype
if mime:
mimetypes_registry = getToolByName(self.getPortalObject(), mimetypes_registry = getToolByName(self.getPortalObject(),
'mimetypes_registry') 'mimetypes_registry')
mimetype_object_list = mimetypes_registry.lookup(mime) mimetype_object_list = mimetypes_registry.lookup(mime)
......
...@@ -2616,6 +2616,19 @@ return 1 ...@@ -2616,6 +2616,19 @@ return 1
self.assertEqual('archived', document_nolang_005.getValidationState()) self.assertEqual('archived', document_nolang_005.getValidationState())
self.assertEqual('shared_alive', document_nolang_006.getValidationState()) self.assertEqual('shared_alive', document_nolang_006.getValidationState())
def testFileWithNotDefinedMimeType(self):
upload_file = makeFileUpload('TEST-001-en.dummy')
kw = dict(file=upload_file, synchronous_metadata_discovery=True,
portal_type='File')
document = self.portal.Base_contribute(**kw)
document.setReference('TEST')
request = self.app.REQUEST
download_file = document.index_html(REQUEST=request, format=None)
self.assertEquals(download_file, 'foo\n')
document_format = None
self.assertEquals('TEST-001-en.dummy', document.getStandardFilename(
document_format))
class TestDocumentWithSecurity(TestDocumentMixin): class TestDocumentWithSecurity(TestDocumentMixin):
username = 'yusei' username = 'yusei'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment