##// END OF EJS Templates
file-store: expose additional headers, and content-disposiztion for nicer downloads
milka -
r4609:a3bacd67 stable
parent child Browse files
Show More
@@ -57,7 +57,6 b' class FileStoreView(BaseAppView):'
57 return _content_type, _encoding
57 return _content_type, _encoding
58
58
59 def _serve_file(self, file_uid):
59 def _serve_file(self, file_uid):
60
61 if not self.storage.exists(file_uid):
60 if not self.storage.exists(file_uid):
62 store_path = self.storage.store_path(file_uid)
61 store_path = self.storage.store_path(file_uid)
63 log.debug('File with FID:%s not found in the store under `%s`',
62 log.debug('File with FID:%s not found in the store under `%s`',
@@ -112,8 +111,19 b' class FileStoreView(BaseAppView):'
112 # For file store we don't submit any session data, this logic tells the
111 # For file store we don't submit any session data, this logic tells the
113 # Session lib to skip it
112 # Session lib to skip it
114 setattr(self.request, '_file_response', True)
113 setattr(self.request, '_file_response', True)
115 return FileResponse(file_path, request=self.request,
114 response = FileResponse(
116 content_type=content_type, content_encoding=content_encoding)
115 file_path, request=self.request,
116 content_type=content_type, content_encoding=content_encoding)
117
118 file_name = db_obj.file_display_name
119
120 response.headers["Content-Disposition"] = (
121 'attachment; filename="{}"'.format(str(file_name))
122 )
123 response.headers["X-RC-Artifact-Id"] = str(db_obj.file_store_id)
124 response.headers["X-RC-Artifact-Desc"] = str(db_obj.file_description)
125 response.headers["X-RC-Artifact-Sha256"] = str(db_obj.file_hash)
126 return response
117
127
118 @LoginRequired()
128 @LoginRequired()
119 @NotAnonymous()
129 @NotAnonymous()
General Comments 0
You need to be logged in to leave comments. Login now