Make a copy of an asset in Portfolio



I had a quick question, if anyone can help. I’m trying to make a duplicate of a Portfolio asset, and I was wondering if there is an easy way to do this in the API. I could go about it the long way, by getting all of the asset info and re-adding it, but I wanted to make sure there wasn’t a simpler and more efficient way.






Why are you trying to make a duplicate? I’m just trying to get an idea of what you are trying to accomplish.
Does it need to be an exact duplicate, or the same image, but different format.

Do you want this copy to be in the Portfolio database?



Hey Matt,

It should be an exact duplicate, then I’ll make some changes to a couple different values using updateAssetFieldValues. I’d like the copy to be in the Portfolio database. Right now we have a script that essentially accesses the database directly and goes through, line by line, and copies the metadata over to a new RID (it makes a couple changes, but they’re very small). I’m trying to re-create this script to using the API.





Sorry for my delay in replying. I wanted to do some proof of concept tests before responding.

I’ve included some code that will make a renamed duplicate of an image. Unfortunately, it does not appear to be an exact duplicate, because it is missing the metadata. But it should be possible to extract the metadata from the original file and embed it into the new file once it is created.


require_once 'AssetSEIService.php';
require_once 'ps-functions.php';

// Variables ================================================
$SERVER_PORT = "8090";
$cname = 'catalog.fdb';

// Main Code ================================================

$session['service'] = new AssetSEIService("http://$SERVER_ADDRESS:$SERVER_PORT/ws/1.0/AssetService?wsdl");
$session['sid'] = pLogin($username, $password, $session['service']);
$session['cid'] = getCatalog($session, $cname);

$myJob = new job();
$myJob->sourceImage = SourceImage::ORIGINAL;

$renameTask = new Task();
$renameTask->type = TaskType::RENAME;
$renameSettings = array(
    0 => buildAtt(TaskSetting::AUTO_RENAME, null),
    1 => buildAtt(TaskSetting::FRONT_RENAME_TYPE, RenameType::TEXT),
    2 => buildAtt(TaskSetting::FRONT_RENAME_VALUE, "BookCover"),
    3 => buildAtt(TaskSetting::MIDDLE_RENAME_TYPE, renameType::TEXT),
    4 => buildAtt(taskSetting::MIDDLE_RENAME_VALUE, "-"),
    5 => buildAtt(TaskSetting::END_RENAME_TYPE, renameType::NUMBER_FROM),
    6 => buildAtt(TaskSetting::END_RENAME_VALUE, "1")
$renameTask->settings = $renameSettings;

$saveTask = new Task();
$saveTask->type = TaskType::SAVE_ON_DISK;
$saveSettings = array(
    0 => buildAtt(TaskSetting::DESTINATION, "sameFolder"),
    1 => buildAtt(TaskSetting::ADD_TO_CATALOG, "true")
$saveTask->settings = $saveSettings;
// You must specify an array, even if there are no settings to apply.

// Collect the tasks and add them to the Job
$myJob->tasks = array(0 => $renameTask, 1 => $saveTask);

//An AssetQuery is used to identify which assets the Job will target.
$aQuery = new AssetQuery();

$qTerm = new AssetQueryTerm();

$qTerm->fieldName = "Filename";
$qTerm->operator = queryOperator::STARTS_WITH_VALUE;
$qTerm->subqueries = array();
$qTerm->values = array(0 => "bookJacket");

$aQuery->queryTerm = $qTerm;

//Run the job
$runJob = new runJob();
$runJob->sessionId = $session['sid'];
$runJob->catalogId = $session['cid'];
$runJob->assets = $aQuery;
$runJob->job = $myJob;
$jobResponse = $session['service']->runJob($runJob);
$myJobId = $jobResponse->return;


If you have any questions about this code, please let me know.