mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
Merge branch 'sas' into 'master'
Fixed some issues with filepaths and see the future with some preload See merge request !59
This commit is contained in:
@ -38,10 +38,11 @@ def send_file(request, file_id, file_class=SithFile, file_attr="file"):
|
||||
):
|
||||
raise PermissionDenied
|
||||
name = f.__getattribute__(file_attr).name
|
||||
with open((settings.MEDIA_ROOT + name).encode('utf-8'), 'rb') as filename:
|
||||
filepath = os.path.join(settings.MEDIA_ROOT, name)
|
||||
with open(filepath.encode('utf-8'), 'rb') as filename:
|
||||
wrapper = FileWrapper(filename)
|
||||
response = HttpResponse(wrapper, content_type=f.mime_type)
|
||||
response['Content-Length'] = os.path.getsize((settings.MEDIA_ROOT + name).encode('utf-8'))
|
||||
response['Content-Length'] = os.path.getsize(filepath.encode('utf-8'))
|
||||
response['Content-Disposition'] = ('inline; filename="%s"' % f.name).encode('utf-8')
|
||||
return response
|
||||
|
||||
|
Reference in New Issue
Block a user