Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 11a2327

Browse files
committed
ENH: refs #975. Support single bitstream download as well
1 parent 665ccf7 commit 11a2327

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

core/controllers/DownloadController.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,23 @@ public function folderAction()
348348
$this->_forward('index', null, null, array('folders' => $pathParams[0]));
349349
}
350350

351+
/**
352+
* This action exposes downloading a single bitstream and should be called as
353+
* download/bitstream/<bitstream_id>/...
354+
* Any extra parameters are ignored and can be used to force clients like wget to download to the correct filename
355+
* if the content-disposition header is ignored by the user agent.
356+
*/
357+
public function bitstreamAction()
358+
{
359+
$pathParams = UtilityComponent::extractPathParams();
360+
if(empty($pathParams))
361+
{
362+
throw new Zend_Exception('Must specify bitstream id as a path parameter');
363+
}
364+
365+
$this->_forward('index', null, null, array('bitstream' => $pathParams[0]));
366+
}
367+
351368
/**
352369
* Render the view for the large data downloader applet
353370
* @param itemIds Comma separated list of items to download

core/views/item/view.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ foreach($cssArray as $module => $list)
220220
echo ' <span name="sizeBytes">'.$bitstream->getSizebytes().'</span>';
221221
echo ' <span name="mimeType">'.$bitstream->getMimetype().'</span>';
222222
echo ' </div>';
223-
echo '<a href="'.$this->webroot.'/download?bitstream='.$bitstream->getKey().'">';
223+
echo '<a href="'.$this->webroot.'/download/bitstream/'.$bitstream->getKey().'/'.urlencode($bitstream->getName()).'">';
224224
echo $this->slicename($bitstream->getName(), 50);
225225
echo '</a>';
226226
if($this->isModerator)

0 commit comments

Comments
 (0)