File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -260,6 +260,56 @@ def subdomain_index(doi):
260260 return resp
261261
262262
263+ @dataset_bp .route ("/doi/<path:doi>/files/raw/<path:filename>" , methods = ["GET" ])
264+ @dataset_bp .route ("/doi/<path:doi>/files/raw/<path:filename>/" , methods = ["GET" ])
265+ def doi_file_raw (doi , filename ):
266+
267+ new_doi = doi_mapping_service .get_new_doi (doi )
268+ if new_doi :
269+ return redirect (
270+ url_for ("dataset.doi_file_raw" , doi = new_doi , filename = filename ),
271+ code = 302 ,
272+ )
273+
274+ ds_meta_data = dsmetadata_service .filter_by_doi (doi )
275+ if not ds_meta_data :
276+ abort (404 )
277+
278+ dataset = ds_meta_data .dataset
279+
280+ selected_file = None
281+ for fm in dataset .feature_models :
282+ for hf in fm .hubfiles :
283+ if hf .name == filename :
284+ selected_file = hf
285+ break
286+ if selected_file :
287+ break
288+
289+ if not selected_file :
290+ abort (404 , description = "File not found in this DOI dataset" )
291+
292+ file_path = os .path .join (
293+ current_app .root_path ,
294+ ".." ,
295+ "uploads" ,
296+ f"user_{ dataset .user_id } " ,
297+ f"dataset_{ dataset .id } " ,
298+ "uvl" ,
299+ selected_file .name ,
300+ )
301+
302+ if not os .path .exists (file_path ):
303+ abort (404 , description = "File missing on disk" )
304+
305+ return send_file (
306+ file_path ,
307+ mimetype = "text/plain; charset=utf-8" ,
308+ as_attachment = False ,
309+ download_name = selected_file .name ,
310+ )
311+
312+
263313@dataset_bp .route ("/datasets/unsynchronized/<int:dataset_id>/" , methods = ["GET" ])
264314@login_required
265315@is_dataset_owner
You can’t perform that action at this time.
0 commit comments