mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Allow export of binary file data
- Use io.BytesIO for non-string-data file objects
This commit is contained in:
parent
5d887f3785
commit
8948536f0f
@ -23,7 +23,10 @@ def DownloadFile(data, filename, content_type='application/text'):
|
|||||||
|
|
||||||
filename = WrapWithQuotes(filename)
|
filename = WrapWithQuotes(filename)
|
||||||
|
|
||||||
wrapper = FileWrapper(io.StringIO(data))
|
if type(data) == str:
|
||||||
|
wrapper = FileWrapper(io.StringIO(data))
|
||||||
|
else:
|
||||||
|
wrapper = FileWrapper(io.BytesIO(data))
|
||||||
|
|
||||||
response = StreamingHttpResponse(wrapper, content_type=content_type)
|
response = StreamingHttpResponse(wrapper, content_type=content_type)
|
||||||
response['Content-Length'] = len(data)
|
response['Content-Length'] = len(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user