File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
phylesystem_api/phylesystem_api/views Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,16 @@ def is_valid_collection_id(doc_id):
6868def fetch_collection (request ):
6969 # NB - This method does not require authentication!
7070 collection_id = request .matchdict ["collection_id" ]
71+
72+ # if '.json' was added to the URL, specify as download
73+ if collection_id .endswith ('.json' ):
74+ # save this as a filename WITHOUT slashes
75+ preferred_filename = collection_id .replace ('/' ,'_' )
76+ # ADD content-disposition header
77+ response = request .response
78+ response .headers ["Content-Disposition" ] = "attachment; filename={};" .format (preferred_filename )
79+ collection_id = collection_id [0 :- 5 ] # trim the '.json' extension and proceed w/ fetch
80+
7181 result = fetch_doc (
7282 request ,
7383 doc_id = collection_id ,
You can’t perform that action at this time.
0 commit comments