You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1013 B
36 lines
1013 B
13 years ago
|
<?php
|
||
13 years ago
|
|
||
13 years ago
|
/**
|
||
|
* @file datastream.inc
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @global object $user
|
||
|
* @param string $object_id
|
||
|
* @param string $dsid
|
||
|
* @return stream
|
||
13 years ago
|
* prints datastream to browser
|
||
13 years ago
|
*/
|
||
13 years ago
|
function islandora_datastream_as_attachment($object_id, $dsid) {
|
||
13 years ago
|
module_load_include('inc', 'islandora', 'RestConnection');
|
||
|
global $user;
|
||
|
try {
|
||
|
$restConnection = new RestConnection($user);
|
||
|
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
|
||
|
} catch (Exception $e) {
|
||
|
drupal_set_message(t('Error getting Islanndora datastream $d for object %s', array('%s' => $object_id, '%d' => $dsid)), 'error');
|
||
|
return"";
|
||
|
}
|
||
13 years ago
|
header('Content-type: ' . $fedora_object[$dsid]->mimetype);
|
||
|
header('Content-length: ' . $fedora_object[$dsid]->size);
|
||
13 years ago
|
header("Cache-control: private");
|
||
|
$method = arg(5);
|
||
13 years ago
|
if (isset($method) && $method == 'download') {
|
||
|
header("Content-Disposition: attachment; filename=\"" . $fedora_object[$dsid]->label);
|
||
13 years ago
|
}
|
||
13 years ago
|
print($fedora_object[$dsid]->content);
|
||
13 years ago
|
exit();
|
||
|
}
|
||
13 years ago
|
|