Apparently the Dropbox thing I’d looked at first wasn’t quite what it should have been. It actually turned out to be straight forward enough that I could put an example together while waiting in line.
Here’s an example similar to the iCloud one above. As long as you have the folders in place you should be good to go. Hopefully the comments explain enough for how it works.
//Create Dropbox object
let dbxMain = Dropbox.create()
//Build some file info
let strID = Date.now()
let strSource = "/Temp/source/" + strID+ "_test.txt"
let strDestination = "/Temp/destination/" + strID+ "_test.txt"
let strContent = "doh rei mi fah so lah tee doh"
//Write a test file and show what the content is for the source and destination
dbxMain.write(strSource, strContent, "overwrite", "false")
//Source should be the content and destination should be undefined
alert("Source:\n" + dbxMain.read(strSource))
alert("Destination:\n" + dbxMain.read(strDestination))
//Build the arguments for calling the Dropbox move
let urlEndpoint = "https://api.dropboxapi.com/2/files/move_v2";
let dictArgs = {
"from_path": strSource,
"to_path": strDestination,
"allow_shared_folder": false,
"autorename": false,
"allow_ownership_transfer": false
};
//Move the file
let objResp = dbxMain.rpcRequest(
{
"url": urlEndpoint,
"method": "POST",
"data": dictArgs
});
//Baseline check if it worked
if (objResp.statusCode != 200)
{
//It didn't :o(
alert("Dropbox Returned an Error: [" + objResp.statusCode + "] " + objResp.error)
context.fail()
}
else
{
//It did :o)
//Show what the content is for the source and destination
//Source should be undefined and destination should be the content
alert("Source:\n" + dbxMain.read(strSource))
alert("Destination:\n" + dbxMain.read(strDestination))
}
Hope that helps.