POST http://yourserver.com/services/copy ?source=<source path> &target=<destination path> &folderReplacePolicy=<AUTO_RENAME | MERGE | THROW_EXCEPTION> &fileReplacePolicy=<AUTO_RENAME | OVERWRITE | OVERWRITE_IF_NEWER | REMOVE_SOURCE | THROW_EXCEPTION | DO_NOTHING> &filterQuery=<query> &flattenFolders=<true | false> &async=<true | false> |
What does it do?
Copy a folder or a single asset.
When you copy a folder, all subfolders and assets contained in it will also be copied to the new location. The subfolder structure will be kept intact unless you set flattenFolder to true.
POST requests only
This REST API only accepts POST requests, not GET requests. Also, the POST request needs to include a cross-site request forgery (csrf) token.
The csrf token is a unique code which, by including it in the request, also makes the POST request unique and therefore much more secure.
The csrf token is obtained by first logging in to Elvis Server through a POST request. The response that is received will include the csrf token which can then be used in subsequent POST requests as a http header:
"X-CSRF-TOKEN: <some_csrf_token>"
For more information including examples, see Elvis 6 REST API - Performing a POST request with a csrf token.
Parameters
source |
Either a folderPath or assetPath of the folder or asset to be copied. Required |
target |
The folderPath or assetPath to which the folder or asset should be copied. Required |
folderReplacePolicy |
Policy used when destination folder already exists.
Optional. If omitted, AUTO_RENAME will be used. |
fileReplacePolicy |
Policy used when destination asset already exists.
Optional. If omitted, AUTO_RENAME will be used. |
filterQuery |
When specified, only source assets that match this query will be copied. Optional. If omitted, all source assets will be copied. |
flattenFolders |
When set to true will copy all files from source subfolders to directly below the target folder. This will 'flatten' any subfolder structure. Optional. If omitted, folders will not be flattened. |
async |
When true, the process will run asynchronous in the background. The call will return immediate with the processId. Optional. By default, the call waits for the process to finish and then returns the processedCount. |
Return value
The operation returns a JSON object with the following properties:
processedCount | Number of assets that were processed by the operation. |
errorCount | Number of errors that occurred. |
If called with async=true, the operation returns a JSON object with the following properties:
processId | Unique id of the process that was started. |
If the operation fails, a JSON error object is returned.
Examples
Copy single asset
The following copies an asset.
copy http://demo.elvisdam.com/services/copy ?source=/Demo Zone/Images/Travel/Architecture/Louvre.jpg &target=/Demo Zone/Images/Travel/Cities/Louvre.jpg |
It returns the following response.
{
"processedCount" : 1
}
Copy folder
The following copies a folder and all the assets contained in it, keeping the sub folder structure intact.
copy http://demo.elvisdam.com/services/copy ?source=/Demo Zone/Images &target=/Production/This week/Demo Images |
Document history
- 27 July 2017: Added section 'Post requests only'.
Comment
Do you have corrections or additional information about this article? Leave a comment! Do you have a question about what is described in this article? Please contact Support.
3 comments
Hello Michael,
Thank you for your question.
The Copy API has no parameters to apply metadata and it doesn't return the new assets id field.
I have no good alternative options for you, but some thoughts:
- Create new asset with required information from the original and the additional metadata.
- Find the asset with help of creation date and the masterId field (which would be set to the id of the original asset).
Kind regards,
Vincent
Assuming you know the ID of the asset you are making a copy of, you can then do a search for where that ID is the ID of Original (i.e. masterId:{OrigID} ). Of course this could return multiple images if it was copied multiple times, so you may need to account for that depending on your workflow.
If we want to apply new metadata to the copied asset, how do we do this?
Can the metadata be sent as part of the COPY request?
Alternatively, how do we get the new asset ID once the asset has been copied? (performing a search after the copy doesn't always return a result)
Please sign in to leave a comment.