Drafts Script Reference

OneDrive

OneDrive objects can be used to work with files in a OneDrive account.

Properties

Functions

Class Functions

Examples

// create OneDrive object
var drive = OneDrive.create();

// setup variables
var path = "/test/file.txt";
var content = "text to place in file";

// write to file on OneDrive
var success = drive.write(path, content, false);

if (success) { // write worked!
  var driveContent = drive.read(path);
  if (driveContent) { // read worked!
    if (driveContent == content) {
      alert("File contents match!");
    }
    else {
      console.log("File did not match");
      context.fail();
    }
  }
  else { // read failed, log error
    console.log(drive.lastError);
    context.fail();
  }
}
else { // write failed, log error
  console.log(drive.lastError);
  context.fail();
}