diff --git a/lib/galaxy/webapps/galaxy/api/datasets.py b/lib/galaxy/webapps/galaxy/api/datasets.py index d159ae96110..b95953aa96b 100644 --- a/lib/galaxy/webapps/galaxy/api/datasets.py +++ b/lib/galaxy/webapps/galaxy/api/datasets.py @@ -256,12 +256,12 @@ class FastAPIDatasets: trans=DependsOnTrans, history_id: EncodedDatabaseIdField = HistoryIDPathParam, history_content_id: EncodedDatabaseIdField = DatasetIDPathParam, - metadata_file: Optional[str] = Query( - default=None, + metadata_name: str = Query( + ..., description="The name of the metadata file to retrieve.", ), ): - metadata_file_path, headers = self.service.get_metadata_file(trans, history_content_id, metadata_file) + metadata_file_path, headers = self.service.get_metadata_file(trans, history_content_id, metadata_name) return FileResponse(path=cast(str, metadata_file_path), headers=headers) @router.get( @@ -446,13 +446,13 @@ class DatasetsController(BaseGalaxyAPIController): return self.service.get_content_as_text(trans, dataset_id) @web.expose_api_raw_anonymous_and_sessionless - def get_metadata_file(self, trans, history_content_id, history_id, metadata_file=None, **kwd): + def get_metadata_file(self, trans, history_content_id, history_id, metadata_name, **kwd): """ GET /api/histories/{history_id}/contents/{history_content_id}/metadata_file """ # TODO: remove open_file parameter when deleting this legacy endpoint metadata_file, headers = self.service.get_metadata_file( - trans, history_content_id, metadata_file, open_file=True + trans, history_content_id, metadata_name, open_file=True ) trans.response.headers.update(headers) return metadata_file diff --git a/lib/galaxy/webapps/galaxy/services/datasets.py b/lib/galaxy/webapps/galaxy/services/datasets.py index 13346681041..6ca3ea63ee8 100644 --- a/lib/galaxy/webapps/galaxy/services/datasets.py +++ b/lib/galaxy/webapps/galaxy/services/datasets.py @@ -434,7 +434,7 @@ class DatasetsService(ServiceBase, UsesVisualizationMixin): self, trans: ProvidesHistoryContext, history_content_id: EncodedDatabaseIdField, - metadata_file: Optional[str] = None, + metadata_name: str, open_file: bool = False, ): """ @@ -445,12 +445,12 @@ class DatasetsService(ServiceBase, UsesVisualizationMixin): """ decoded_content_id = self.decode_id(history_content_id) hda = self.hda_manager.get_accessible(decoded_content_id, trans.user) - file_ext = hda.metadata.spec.get(metadata_file).get("file_ext", metadata_file) + file_ext = hda.metadata.spec.get(metadata_name).get("file_ext", metadata_name) fname = "".join(c in util.FILENAME_VALID_CHARS and c or "_" for c in hda.name)[0:150] headers = {} headers["Content-Type"] = "application/octet-stream" headers["Content-Disposition"] = f'attachment; filename="Galaxy{hda.hid}-[{fname}].{file_ext}"' - file_path = hda.metadata.get(metadata_file).file_name + file_path = hda.metadata.get(metadata_name).file_name if open_file: return open(file_path, "rb"), headers return file_path, headers