Options
All
  • Public
  • Public/Protected
  • All
Menu

Box

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

Examples

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

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

// write to file on Box
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();
}

Hierarchy

  • Box

Index

Properties

Methods

Properties

Optional lastError

lastError: string

Methods

read

  • read(path: string): string
  • Reads the contents of the file at the path as a string. Returns undefined value if the file does not exist or could not be read. Paths should begin with a / and be relative to the root directory of your Box.com account.

    Parameters

    • path: string

    Returns string

write

  • write(path: string, content: string, overwrite?: boolean): 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

    • path: string

      Paths should begin with a / and be relative to the root directory of your Box

    • content: string

      Text to place in the file.

    • Optional overwrite: boolean

      If false, an existing file will not be overwritten.

    Returns boolean

Static create

  • create(identifier?: string): Box
  • Creates a new Box object. Identifier is a optional string value used to identify a Box.com account. Typically this can be omitted if you only work with one Box.com account in Drafts.

    Parameters

    • Optional identifier: string

    Returns Box

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