File tree Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Original file line number Diff line number Diff line change 1
- 7.0.0
1
+ 7.0.1
Original file line number Diff line number Diff line change @@ -200,18 +200,28 @@ def send_file(self, as_attachment: bool):
200
200
raise FileNotFoundError (errno .ENOENT , 'File not found' , self .path )
201
201
elif self .root_fs .hassyspath (self .path ):
202
202
# Local filesystem
203
- return send_file (
204
- self .root_fs .getsyspath (self .path ),
205
- as_attachment = as_attachment ,
206
- attachment_filename = self .name if as_attachment else None ,
207
- )
203
+ if as_attachment :
204
+ # Send file as attachment (set Content-Disposition: attachment header)
205
+ try :
206
+ # flask >= 2.0 - download_name replaces the attachment_filename
207
+ return send_file (
208
+ self .root_fs .getsyspath (self .path ),
209
+ as_attachment = True ,
210
+ download_name = self .name ,
211
+ )
212
+ except TypeError :
213
+ return send_file (
214
+ self .root_fs .getsyspath (self .path ),
215
+ as_attachment = True ,
216
+ )
217
+ else :
218
+ return send_file (self .root_fs .getsyspath (self .path ))
208
219
else :
209
220
# Other filesystems
210
221
response = Response (stream_with_context (self .read_file_chunks ()))
211
222
if as_attachment :
212
- response .headers [
213
- 'Content-Disposition'
214
- ] = 'attachment;filename={}' .format (self .name )
223
+ content_disposition = 'attachment;filename={}' .format (self .name )
224
+ response .headers ['Content-Disposition' ] = content_disposition
215
225
return response
216
226
217
227
def write_file (self , data : Union [str , bytes ], is_text : bool ) -> None :
Original file line number Diff line number Diff line change 405
405
406
406
- Raise the correct exception at file loading and show the error in the editor
407
407
- Fix exception related to https://github.com/axios/axios/issues/811
408
+
409
+ ## 7.0.1
410
+
411
+ 2022-08-25
412
+
413
+ ### Fix
414
+
415
+ - Fix "send_file() got an unexpected keyword argument 'attachment_filename'" exception for new version of Flask
You can’t perform that action at this time.
0 commit comments