Skip to content

Instantly share code, notes, and snippets.

@dltj
Last active December 20, 2015 03:19
Show Gist options
  • Save dltj/6063275 to your computer and use it in GitHub Desktop.
Save dltj/6063275 to your computer and use it in GitHub Desktop.
Modify datastream within PHP using tuque
<?php
module_load_include('inc', 'islandora_basic_image', 'includes/derivatives');
$pid = "islandora:13";
$fedora_object = islandora_object_load($pid);
if (!$fedora_object) {
drupal_set_message("Fedora Object isn't in the repo!");
}
if (!isset($fedora_object["OBJ"])) {
$obj_datastream = $fedora_object->constructDatastream('OBJ', 'M');
}
else {
$obj_datastream = $fedora_object["OBJ"];
}
//dpr($obj_datastream);
$obj_datastream->label = 'OBJ';
$obj_datastream->mimetype = 'image/png';
$obj_datastream->setContentFromUrl('http://ratatosk.net/assets/screenshots/debugging-drupal/devel-dpr.png');
$fedora_object->ingestDatastream($obj_datastream);
islandora_basic_image_create_all_derivatives($fedora_object);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment