|
|
@ -513,14 +513,10 @@ def send_file(filename_or_fp, mimetype=None, as_attachment=False, |
|
|
|
|
|
|
|
|
|
|
|
if mimetype is None: |
|
|
|
if mimetype is None: |
|
|
|
if attachment_filename is not None: |
|
|
|
if attachment_filename is not None: |
|
|
|
mimetype = mimetypes.guess_type(attachment_filename)[0] |
|
|
|
mimetype = mimetypes.guess_type(attachment_filename)[0] \ |
|
|
|
|
|
|
|
or 'application/octet-stream' |
|
|
|
|
|
|
|
|
|
|
|
if mimetype is None: |
|
|
|
if mimetype is None: |
|
|
|
if attachment_filename is not None: |
|
|
|
|
|
|
|
raise ValueError( |
|
|
|
|
|
|
|
'Unable to infer MIME-type from filename {0!r}, please ' |
|
|
|
|
|
|
|
'pass one explicitly.'.format(attachment_filename) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
raise ValueError( |
|
|
|
raise ValueError( |
|
|
|
'Unable to infer MIME-type because no filename is available. ' |
|
|
|
'Unable to infer MIME-type because no filename is available. ' |
|
|
|
'Please set either `attachment_filename`, pass a filepath to ' |
|
|
|
'Please set either `attachment_filename`, pass a filepath to ' |
|
|
|