소스 검색

set filename and default content type when downloading files

damien 11 년 전
부모
커밋
22a500fc60
1개의 변경된 파일7개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 2
      pboard/pboard/controllers/api.py

+ 7 - 2
pboard/pboard/controllers/api.py 파일 보기

@@ -134,9 +134,14 @@ class PODApiController(BaseController):
134 134
       else:
135 135
         loCurrentUser   = pld.PODStaticController.getCurrentUser()
136 136
         loApiController = pld.PODUserFilteredApiController(loCurrentUser.user_id)
137
-        
138 137
         loFile = loApiController.getNode(node_id)
139
-        tg.response.headers['Content-type'] = str(loFile.data_file_mime_type)
138
+
139
+        lsContentType = "application/x-download"
140
+        if loFile.data_file_mime_type!='':
141
+          tg.response.headers['Content-type'] = str(loFile.data_file_mime_type)
142
+
143
+        tg.response.headers['Content-Type']        = lsContentType
144
+        tg.response.headers['Content-Disposition'] = str('attachment; filename="%s"'%(loFile.data_file_name))
140 145
         return loFile.data_file_content
141 146
 
142 147
     @expose()