On Javascript, I am using Live SDK REST API (this is an API for One Drive basic REST services as described here : https://msdn.microsoft.com/en-us/library/hh826531.aspx ) and I am trying to implement a "Make a copy of file/ duplicate" action, so to create duplicates (with changed names) on my current path. When I am making a COPY request as here (where path is my file that I want to copy and destination is its current folder):
function copyFile_onClick() {
WL.login({
scope: "wl.skydrive_update"
}).then(
function (response) {
WL.api({
path: "file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!141",
method: "COPY",
body: {
destination: "folder.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!125"
}
}).then(
function (response) {
document.getElementById("infoArea").innerText = "Item copied.";
},
function (responseFailed) {
document.getElementById("infoArea").innerText =
"Error calling API: " + responseFailed.error.message;
}
);
},
function (responseFailed) {
document.getElementById("infoArea").innerText =
"Login error: " + responseFailed.error_description;
}
);
}
I am getting error response, as resource already exists there (which is totally reasonable). However, I cannot find a way to add a filenameCopy1 parameter on the request so to avoid that.
So, the only way I am thinking to do the cloning is having a temp folder to copy the file, then rename it with filenameCopy1 and then move it back to the current folder. That process is really slow and not so safe (eg. what if only one action happens).
Any advice really appreciated. Thanks.