renaming files with WS
I'm trying to automate some file-naming cleanup with Web Services, but I don't seem to be able to actually rename files. It will appear to have worked but the change never actually happens. I can change other fields (for example, "text" and "displayName"), but the "name" field is stubborn. I tried in 7.8.4 as well as 7.10.
Here's my code:
function renameFile ($fileReadID, $auth, $cascade) {
$id = array('id' => $fileReadID, 'type' => 'file');
$readParams = array( 'authentication' => $auth, 'identifier' => $id );
$pageRead=$cascade->read($readParams);
$asset = $pageRead->readReturn->asset->file;
$fullName = $asset->name;
$fullPath = $asset->path;
$fileExt = substr($fullName,strrpos($fullName,'.'));
$newFileName = 'some-new-filename.txt';
if ($newFileName != $fullName) {
$asset->name = $newFileName;
$editParams = array('authentication' => $auth, 'asset' => array('file' => $asset));
$cascade->edit($editParams);
$result = $cascade->__getLastResponse();
getResultAction($result,$newFileName,"Renamed.");
}
}
The response I get is this:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><editResponse xmlns="http://www.hannonhill.com/ws/ns/AssetOperationService"><editReturn><message xsi:nil="true" /><success>true</success></editReturn></editResponse></soapenv:Body></soapenv:Envelope>
Is there another method I need to use to rename other than edit? I know I could do a read/create/delete, but I'd rather avoid that if possible.
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Wing Ming Chan on Mar 30, 2014 @ 02:41 PM
Hi Eric,
You need to use the
move
operation by passing indestinationContainerIdentifier
,doWorkflow
, andnewName
.Wing
2 Posted by Eric L. Epps on Mar 31, 2014 @ 01:38 PM
Thanks, Wing!
For reference, here's the updated function:
Eric L. Epps closed this discussion on Mar 31, 2014 @ 01:54 PM.