mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
parent
93a2d612e2
commit
7372f2b714
@ -525,6 +525,7 @@ def DownloadFile(data, filename, content_type='application/text', inline=False)
|
||||
A StreamingHttpResponse object wrapping the supplied data
|
||||
"""
|
||||
filename = WrapWithQuotes(filename)
|
||||
length = len(data)
|
||||
|
||||
if type(data) == str:
|
||||
wrapper = FileWrapper(io.StringIO(data))
|
||||
@ -532,7 +533,9 @@ def DownloadFile(data, filename, content_type='application/text', inline=False)
|
||||
wrapper = FileWrapper(io.BytesIO(data))
|
||||
|
||||
response = StreamingHttpResponse(wrapper, content_type=content_type)
|
||||
response['Content-Length'] = len(data)
|
||||
if type(data) == str:
|
||||
length = len(bytes(data, response.charset))
|
||||
response['Content-Length'] = length
|
||||
|
||||
disposition = "inline" if inline else "attachment"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user