forked from orbit-oss/flask
Do not error for unknown files if send_file sends an actual file
This commit is contained in:
parent
c54c538c11
commit
a30951ec28
2 changed files with 3 additions and 4 deletions
|
|
@ -513,7 +513,8 @@ 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:
|
if attachment_filename is not None:
|
||||||
|
|
|
||||||
|
|
@ -402,9 +402,7 @@ class TestSendfile(object):
|
||||||
assert 'no filename is available' in str(excinfo)
|
assert 'no filename is available' in str(excinfo)
|
||||||
|
|
||||||
with app.test_request_context():
|
with app.test_request_context():
|
||||||
with pytest.raises(ValueError) as excinfo:
|
flask.send_file(StringIO("LOL"), attachment_filename='filename')
|
||||||
flask.send_file(StringIO("LOL"), attachment_filename='filename')
|
|
||||||
assert "Unable to infer MIME-type from filename 'filename'" in str(excinfo)
|
|
||||||
|
|
||||||
def test_send_file_object(self):
|
def test_send_file_object(self):
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue