We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 22db231 + fdce137 commit 6ced241Copy full SHA for 6ced241
1 file changed
phylesystem_api/phylesystem_api/views/collection.py
@@ -68,6 +68,16 @@ def is_valid_collection_id(doc_id):
68
def fetch_collection(request):
69
# NB - This method does not require authentication!
70
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
81
result = fetch_doc(
82
request,
83
doc_id=collection_id,
0 commit comments