Moving Sidecar XMLs to a Dedicated Folder

By Patrik - July 2, 2015 (Last updated: April 3, 2017)

What are you doing with you sidecar XMLs after you are done with the import? You can of course delete them, but you can also move or copy them to another folder for keeping.

You can easily do either a move/copy of the sidecar file to a dedicated folder, or delete, with a simple API call. The relevant API calls can be found here for delete, and move/copy.

To delete the sidecar XML you would make a DELETE request to :

http://localhost:8080/API/storage/{source-storage-id}/file/{file-id}

setting the appropriate source-storage-id, and file-id.

To move a file you make a POST request to:

http://localhost:8080/API/storage/{source-storage-id}/file/{file-id}/storage/{target-storage-id}?move=true&filename=new_filename

with query parameter move set to true, and an optional new filename.

To copy the file, set the query parameter move to false instead:

http://localhost:8080/API/storage/{source-storage-id}/file/{file-id}/storage/{target-storage-id}?move=false&filename=new_filename

A simple example in Javascript to start a move job for the files, and at the same time rename them, would look like this:

var oldFilename = api.path("storage/"+srcStorageId+"/file/"+sidecarFileId).get()
var regex = /^(.*)\.([^.]+)$/;
var newFileName = (regex.exec(oldFilename)[0] + ".imported")

api.path("storage/"+srcStorageId+"/file/"+sidecarFileId+"/storage/"+targetStorageId)
  .queryParam("move", "true")
  .queryParam("filename", newFileName)
  .post();

 

Categories

TechnologyVidispine