--- a/src/pyams_file/views/file.py Tue Jun 06 17:31:19 2017 +0200
+++ b/src/pyams_file/views/file.py Thu Jun 08 11:01:13 2017 +0200
@@ -33,20 +33,26 @@
"""Default file view"""
context = request.context
+ # set content type
+ content_type = context.content_type
+ if isinstance(content_type, bytes):
+ content_type = content_type.decode('utf-8')
+
# check for last modification date
modified = IZopeDublinCore(context).modified
if_modified_since = request.if_modified_since
if if_modified_since and (int(modified.timestamp()) <= int(if_modified_since.timestamp())):
- return Response(content_type=context.content_type.decode('utf-8'),
+ return Response(content_type=content_type,
status=NOT_MODIFIED)
- response = Response(content_type=context.content_type.decode('utf-8'),
+ response = Response(content_type=content_type,
last_modified=modified)
body_file = context.get_blob(mode='c')
if request.params.get('download') is not None:
response.content_disposition = 'attachment; filename="{0}"'.format(context.filename)
+ # check for range request
if request.range is not None:
body = body_file.read()
body_length = len(body)