Options
All
  • Public
  • Public/Protected
  • All
Menu

GoogleDrive

GoogleDrive objects can be used to work with files in Google Drive accounts.

Example

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

// setup variables
var fileName = "MyTestFile";
var parent = ""; // root of drive
var content = "text to place in file";

// write to file on GoogleDrive
var success = drive.write(fileName, parent, content);

if (success) { // write worked!
  var driveContent = drive.read(fileName, parent);
  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();
}

Hierarchy

  • GoogleDrive

Index

Properties

Methods

Properties

lastError

lastError: string | undefined

If a function fails, this property will contain the last error as a string message, otherwise it will be undefined.

Methods

read

  • read(fileName: string, parent: string): string | undefined
  • Reads the contents of the file at the with the file name, in the parent folder, as a string. Returns undefined value if the file does not exist or could not be read.

    Parameters

    • fileName: string
    • parent: string

      Name of folder in the root of the Google Drive, or "" for root. FIXME: optional?

    Returns string | undefined

write

  • write(fileName: string, parent: string, content: string): boolean
  • Write the contents of the file at the path. Returns true if successful, false if the file could not be written successfully. This will override existing files!

    Parameters

    • fileName: string
    • parent: string

      Name of folder in the root of the Google Drive, or "" for root.

    • content: string

      Text to write to file.

    Returns boolean

Static create

  • Creates a new GoogleDrive object.

    Parameters

    • Optional identifier: string

      used to identify a GoogleDrive account. Typically this can be omitted if you only work with one GoogleDrive account in Drafts.

    Returns GoogleDrive

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc