Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseFileHandle

Abstract prototype of all all VFS file handle definition.

This prototype provides a standardized interface to access to different underlay file systems such as remote file, cloud file (Dropbox, Google drive, etc.), URL or memory-based file

export
abstract

Hierarchy

Index

Constructors

constructor

Properties

basename

basename: string

File base name

memberof

BaseFileHandle

cache

cache: any

Once read, file content will be cached in this placeholder

memberof

BaseFileHandle

dirty

dirty: boolean

Flag indicates whether the file is dirty

memberof

BaseFileHandle

ext

ext: string

File extension

memberof

BaseFileHandle

genealogy

genealogy: string[]

List of path segments

memberof

BaseFileHandle

info

Once loaded, ready will be set to true and file meta-data will be stored in this place holder

memberof

BaseFileHandle

path

path: string

File path

memberof

BaseFileHandle

protocol

protocol: string

File protocol e.g:

  • os://
  • home://
memberof

BaseFileHandle

ready

ready: boolean

Flag indicated whether the file meta-data is loaded

memberof

BaseFileHandle

type

type: string

File type

memberof

BaseFileHandle

Accessors

filename

  • get filename(): string
  • set filename(v: string): void
  • Getter: Get the file basename Setter: set the file name

    memberof

    BaseFileHandle

    Returns string

  • Getter: Get the file basename Setter: set the file name

    memberof

    BaseFileHandle

    Parameters

    • v: string

    Returns void

Methods

Protected _down

  • _down(): Promise<any>
  • Low level protocol-specific download operation

    This function should be overridden by the file handle class that supports the operation

    memberof

    BaseFileHandle

    Returns Promise<any>

Protected _exec

  • Low level protocol-specific execute operation

    This function should be overridden by the file handle class that supports the operation

    memberof

    BaseFileHandle

    Returns Promise<RequestResult>

Protected _mk

  • Low level protocol-specific sub-directory creation

    This function should be overridden by the file handle class that supports the operation

    memberof

    BaseFileHandle

    Parameters

    • d: string

      sub directory name

    Returns Promise<RequestResult>

Protected _mv

  • Low level protocol-specific move operation

    This function should be overridden by the file handle class that supports the operation

    memberof

    BaseFileHandle

    Parameters

    • d: string

    Returns Promise<RequestResult>

Protected _pub

  • Low level protocol-specific share operation

    This function should be overridden by the file handle class that supports the operation

    memberof

    BaseFileHandle

    Returns Promise<RequestResult>

Protected _rd

  • Low level protocol-specific read operation

    This function should be overridden on the file handle class that supports the operation

    memberof

    BaseFileHandle

    Parameters

    • t: string

      data type, see read

    Returns Promise<RequestResult>

Protected _rm

  • Low level protocol-specific delete operation

    This function should be overridden by the file handle class that supports the operation

    memberof

    BaseFileHandle

    Returns Promise<RequestResult>

Protected _up

  • Low level protocol-specific upload operation

    This function should be overridden by the file handle class that supports the operation

    memberof

    BaseFileHandle

    Returns Promise<RequestResult>

Protected _wr

  • Low level protocol-specific write operation

    This function should be overridden by the file handle class that supports the operation

    memberof

    BaseFileHandle

    Parameters

    • t: string

      data type, see write

    • Optional d: any

    Returns Promise<RequestResult>

asFileHandle

Protected b64

  • b64(t: string): Promise<string | ArrayBuffer>
  • Convert the current file cache to Base64

    memberof

    BaseFileHandle

    Parameters

    • t: string

      type of the file cache:

      • object
      • mime type

    Returns Promise<string | ArrayBuffer>

    promise on the converted data

download

  • download(): Promise<any>
  • Download the file.

    Only work with file

    This function calls the _down function to perform the operation

    memberof

    BaseFileHandle

    Returns Promise<any>

    Promise on the operation result

execute

  • execute(): Promise<any>
  • Execute the current file.

    This action depends on each file protocol

    This function calls the _exec function to perform the operation

    memberof

    BaseFileHandle

    Returns Promise<any>

getlink

  • getlink(): string
  • Get an accessible link to the file that can be accessed from the browser

    memberof

    BaseFileHandle

    Returns string

hash

  • hash(): number
  • Get hash number of the current file path

    memberof

    BaseFileHandle

    Returns number

isHidden

  • isHidden(): boolean
  • Check whether the current file is a hidden file

    memberof

    BaseFileHandle

    Returns boolean

isRoot

  • isRoot(): boolean
  • Check whether the current file is the root of the file tree

    memberof

    BaseFileHandle

    Returns boolean

Abstract meta

  • Read the current file meta-data

    should be implemented by subclasses

    abstract
    memberof

    BaseFileHandle

    Returns Promise<RequestResult>

mk

  • Sub-directory creation

    This function calls the _mk function to perform the operation

    memberof

    BaseFileHandle

    Parameters

    • d: string

      sub directory name

    Returns Promise<RequestResult>

    promise on the operation result

move

  • Move the current file to another location

    This function calls the _mv function to perform the operation

    memberof

    BaseFileHandle

    Parameters

    • d: string

      destination location

    Returns Promise<RequestResult>

    promise on the operation result

onready

  • Load the file meta-data before performing any task

    memberof

    BaseFileHandle

    Returns Promise<FileInfoType>

    a promise on file meta-data

parent

publish

  • Share the file by publish it.

    Only work with file

    This function calls the _pub function to perform the operation

    memberof

    BaseFileHandle

    Returns Promise<RequestResult>

    promise on operation result

read

  • read(t?: string): Promise<any>
  • Public read operation

    This function calls the _rd function to perform the operation.

    If the current file is a directory, then the operation will return the meta-data of all files inside of the directory. Otherwise, file content will be returned

    memberof

    BaseFileHandle

    Parameters

    • Optional t: string

      data type

      • jsonp: the response is an json object
      • script: the response is a javascript code
      • xml, html: the response is a XML/HTML object
      • text: plain text
      • binary

    Returns Promise<any>

    a promise on the file content

remove

  • Delete the file

    This function calls the _rm function to perform the operation

    memberof

    BaseFileHandle

    Returns Promise<RequestResult>

    promise on the operation result

setCache

setPath

  • setPath(p: string): void
  • Set a file path to the current file handle

    memberof

    BaseFileHandle

    Parameters

    • p: string

    Returns void

Protected unsupported

  • Helper function returns a promise on unsupported action

    memberof

    BaseFileHandle

    Parameters

    • t: string

      action name

    Returns Promise<RequestResult>

upload

  • Upload a file to the current directory

    Only work when the current file is a directory

    This function calls the _up function to perform the operation

    memberof

    BaseFileHandle

    Returns Promise<RequestResult>

    promise on the operation result

write

  • Write the file cache to the actual file

    This function calls the _wr function to perform the operation

    memberof

    BaseFileHandle

    Parameters

    • t: string

      data type

      • base64
      • object
      • mime type

    Returns Promise<RequestResult>

    promise on the operation result