mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +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
|
A StreamingHttpResponse object wrapping the supplied data
|
||||||
"""
|
"""
|
||||||
filename = WrapWithQuotes(filename)
|
filename = WrapWithQuotes(filename)
|
||||||
|
length = len(data)
|
||||||
|
|
||||||
if type(data) == str:
|
if type(data) == str:
|
||||||
wrapper = FileWrapper(io.StringIO(data))
|
wrapper = FileWrapper(io.StringIO(data))
|
||||||
@ -532,7 +533,9 @@ def DownloadFile(data, filename, content_type='application/text', inline=False)
|
|||||||
wrapper = FileWrapper(io.BytesIO(data))
|
wrapper = FileWrapper(io.BytesIO(data))
|
||||||
|
|
||||||
response = StreamingHttpResponse(wrapper, content_type=content_type)
|
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"
|
disposition = "inline" if inline else "attachment"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user