diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 9341a6c6..0cb03f00 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -34,11 +34,12 @@ class ObjectHelper { /** * Grabs a stream from fedora sets the mimetype and returns it. $dsID is the - * datastream id. + * datastream id. If $forceSoap is set, the function will always buffer the datastream from fedora. Otherwise, it will + * try and use a redirect if possible. * @param $pid String * @param $dsID String */ - function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL) { + function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = FALSE) { global $user; module_load_include('inc','fedora_repository','ContentModel'); if ($pid == NULL || $dsID == NULL) { @@ -163,7 +164,12 @@ class ObjectHelper { header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"'); } - curl_exec($ch); + + if ( (isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { + curl_exec($ch); + } else { + header('Location: '.$url); + } } curl_close($ch); } else {