Options
All
  • Public
  • Public/Protected
  • All
Menu

External module scripts/backup/drive

Manage interaction with Google Drive https://developers.google.com/drive/v3/web/about-sdk

Index

Type aliases

DriveFileId

DriveFileId: string

Unique ID of a file on Google Drive

Variables

Const APP_FOLDER

APP_FOLDER: "appDataFolder" = "appDataFolder"

Our app folder

Const FILES_PATH

FILES_PATH: "/drive/v3/files/" = "/drive/v3/files/"

Path to drive files api

Const SCOPES

SCOPES: string[] = ['email','profile','https://www.googleapis.com/auth/drive.appfolder',]

Scopes required for drive - override manifest values

remarks

Changing the scopes will create a new Auth token, so we will have two

gapi

gapi: any

Let isApiLoaded

isApiLoaded: boolean = false

Flag to indicate if gapi library has been retrieved

Functions

_deleteFile

_getFiles

_getZipFileContents

  • _getZipFileContents(fileId: DriveFileId): Promise<string>

addScope

  • addScope(): Promise<void>

createOrUpdateZipFile

  • createOrUpdateZipFile(fileId: DriveFileId | null, filename: string, appProps: IAppProps, data: string): Promise<string>
  • Create or update a zip file in our app folder

    Parameters

    • fileId: DriveFileId | null

      if null create new file, otherwise update

    • filename: string
    • appProps: IAppProps

      metadata

    • data: string

      the actual data

    Returns Promise<string>

    file id

createZipFile

  • createZipFile(filename: string, appProps: IAppProps, data: string, interactive?: boolean): Promise<string>
  • Create a zip file in our app folder

    Parameters

    • filename: string
    • appProps: IAppProps

      metadata

    • data: string

      data bytes base 64

    • Default value interactive: boolean = false

      if true, user initiated

    Returns Promise<string>

    file id

deleteFile

  • deleteFile(fileId: DriveFileId, interactive?: boolean, eatError?: boolean): Promise<void>
  • Delete a file in our app folder

    Parameters

    • fileId: DriveFileId
    • Default value interactive: boolean = false

      if true, user initiated

    • Default value eatError: boolean = false

      if true, ignore failed delete

    Returns Promise<void>

getAuthorization

  • getAuthorization(interactive?: boolean): Promise<void>
  • Get an authorized drive client

    Parameters

    • Default value interactive: boolean = false

      if true, user initiated

    Returns Promise<void>

getError

  • getError(prefix: string, reason: IReason): Error
  • Get an Error from a failed gapi call

    Parameters

    • prefix: string

      error prefix text

    • reason: IReason

      reason for failure

    Returns Error

getFiles

  • getFiles(interactive?: boolean): Promise<IDriveFile[]>
  • Get the list of files in our app folder

    Parameters

    • Default value interactive: boolean = false

      if true, user initiated

    Returns Promise<IDriveFile[]>

    Array of Drive file's metadata

getZipFileContents

  • getZipFileContents(fileId: DriveFileId, interactive?: boolean): Promise<string>
  • Get a zip file's content in our app folder

    Parameters

    • fileId: DriveFileId
    • Default value interactive: boolean = false

      if true, user initiated

    Returns Promise<string>

    file data

loadDriveLib

  • loadDriveLib(): Promise<void>

loadLib

  • loadLib(): Promise<void>

updateZipFile

  • updateZipFile(fileId: DriveFileId, name: string, appProps: IAppProps, data: string, interactive?: boolean): Promise<string>
  • Update a zip file in our app folder

    Parameters

    • fileId: DriveFileId
    • name: string

      filename

    • appProps: IAppProps

      metadata

    • data: string

      data bytes

    • Default value interactive: boolean = false

      if true, user initiated

    Returns Promise<string>

    file id

waitForReady

  • waitForReady(): Promise<Object>

Object literals

Const ERR

ERR: object

Error messages

CREATE

CREATE: string = "Failed to create backup on Google Drive."

DELETE

DELETE: string = "Failed to delete backup on Google Drive."

GET

GET: string = "Failed to get backup from Google Drive."

GET_FILES

GET_FILES: string = "Failed to get list of backups from Google Drive."

LOAD_LIB

LOAD_LIB: string = "Failed to load gapi library."

NO_FILE_ID

NO_FILE_ID: string = "No fileId specified."

NO_SIGNIN

NO_SIGNIN: string = "Not signed in."

Generated using TypeDoc