diff --git a/modules/genomic_browser/jsx/tabs_content/files.js b/modules/genomic_browser/jsx/tabs_content/files.js index 0aa6d446690..3e80b07deaa 100644 --- a/modules/genomic_browser/jsx/tabs_content/files.js +++ b/modules/genomic_browser/jsx/tabs_content/files.js @@ -35,6 +35,7 @@ class Files extends Component { }, }; this.fetchData = this.fetchData.bind(this); + this.formatColumn = this.formatColumn.bind(this); this.openFileUploadModal = this.openFileUploadModal.bind(this); this.closeFileUploadModal = this.closeFileUploadModal.bind(this); this.renderFileUploadForm = this.renderFileUploadForm.bind(this); @@ -151,9 +152,16 @@ class Files extends Component { formatColumn(column, cell, rowData, rowHeaders) { let reactElement; switch (column) { + case 'Name': + const fileName = rowData.Name.split('/').pop(); + const url = + `${this.props.baseURL + }/genomic_browser/FileManager?filename=${fileName}`; + reactElement = {fileName}; + break; case 'PSCID': - const url = `${this.props.baseURL}/${rowData.DCCID}/`; - reactElement = {rowData.PSCID}; + const urlPscid = `${this.props.baseURL}/${rowData.DCCID}/`; + reactElement = {rowData.PSCID}; break; case 'Subproject': reactElement = {this.state.data.subprojects[parseInt(cell)]}; diff --git a/modules/genomic_browser/php/filemanager.class.inc b/modules/genomic_browser/php/filemanager.class.inc index 83de23c925a..cde651bb333 100644 --- a/modules/genomic_browser/php/filemanager.class.inc +++ b/modules/genomic_browser/php/filemanager.class.inc @@ -54,6 +54,33 @@ class FileManager extends \NDB_Page implements ETagCalculator */ private function _handleGET(ServerRequestInterface $request) : ResponseInterface { + // Parse GET query params. + $values = $request->getQueryParams(); + // GET request for downloading file by ID. + if ($values['filename']) { + $factory = \NDB_Factory::singleton(); + $config = $factory->config(); + $filesDir = \Utility::appendForwardSlash( + $config->getSetting('GenomicDataPath') + ); + try { + $downloadhandler = new \LORIS\FilesDownloadHandler( + new \SplFileInfo($filesDir) + ); + $request = $request->withAttribute( + 'filename', + $values['filename'] + ); + return $downloadhandler->handle($request); + } catch (\LorisException $e) { + // FilesUploadHandler throws an exception if there's a problem with + // the downloaddir. + return new \LORIS\Http\Response\JSON\InternalServerError( + $e->getMessage() + ); + } + } + $provisioner = new FilesProvisioner(); $user = $request->getAttribute('user'); diff --git a/modules/genomic_browser/php/uploading/genomicfile.class.inc b/modules/genomic_browser/php/uploading/genomicfile.class.inc index f220a0cb836..46a9e209219 100644 --- a/modules/genomic_browser/php/uploading/genomicfile.class.inc +++ b/modules/genomic_browser/php/uploading/genomicfile.class.inc @@ -468,8 +468,10 @@ class Genomicfile function setFullPath(&$fileToUpload) : void { $config = \NDB_Config::singleton(); - $genomic_data_dir = rtrim($config->getSetting('GenomicDataPath'), '/') - . '/genomic_uploader/'; + $genomic_data_dir = rtrim( + $config->getSetting('GenomicDataPath'), + '/' + ) . '/'; $fileToUpload->full_path = $genomic_data_dir . $fileToUpload->file_name;