Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface WAKFileInstance

Hierarchy

Index

Properties

creationDate

creationDate: Date

Creation date for the file.

exists

exists: Boolean

true if the file exists at the defined path, false otherwise.

extension

extension: String

File extension.

lastModifiedDate

lastModifiedDate: any

Last modification date for the file if any.

name

name: string

Name of the file with the extension and without the path.

nameNoExt

nameNoExt: String

Name of the file without the extension.

parent

Parent folder of the file.

path

path: String

Full path of the file.

readOnly

readOnly: Boolean

true if the file is read only, false otherwise.

size

size: number

Size of the Blob in bytes.

type

type: string

Media type of the Blob expressed as MIME or "" if unknown.

visible

visible: Boolean

true if the file is visible, false otherwise.

Methods

copyTo

  • copyTo(destination: String, overwrite?: Boolean): void
  • copyTo(destination: WAKFileInstance, overwrite?: Boolean): void
  • Copies the blob into a file.

    Example 1: Copy a blob

    var myBlob = new Blob( 20 );
    myBlob.copyTo( 'PROJECT/blob_copy.js' );

    or

    var myFile = new File( 'PROJECT/blob_copy.js' );
    var myBlob = new Blob( 20 );
    myBlob.copyTo( myFile );

    Example 2: Copy a file

    var myFile = new File( 'PROJECT/bootstrap.js' );
    myFile.copyTo( 'PROJECT/bootstrap_copy.js' );

    or

    var myFile = new File( 'PROJECT/bootstrap.js' );
    var myFileCopy = new File( 'PROJECT/bootstrap_copy.js' );
    myFile.copyTo( myFileCopy );

    Parameters

    • destination: String

      Destination file

    • Optional overwrite: Boolean

      true to override existing file if any, false otherwise

    Returns void

  • Parameters

    Returns void

create

  • create(): Boolean
  • Creates a new file on disk.

    var myFile = new File( 'PROJECT/my-created-file.js' );
    var myResult = myFile.create();
    console.log( myResult );
    // true
    throws

    An error if something goes wrong: file already exists, invalid path, ...

    Returns Boolean

    true if the file is well created

getFreeSpace

  • getFreeSpace(quotas?: Boolean): Number
  • Returns the size of the free space (expressed in bytes) available on the volume where the File object is stored.

    Parameters

    • Optional quotas: Boolean

      (default: true) true if consider the whole volume, false if consider only the allowed size for the quota

    Returns Number

getURL

  • getURL(encoding?: Boolean): String
  • Returns the absolute URL of the File object.

    Parameters

    • Optional encoding: Boolean

      (default: false) true if encode the url, false otherwise.

    Returns String

getVolumeSize

  • getVolumeSize(): Number
  • Returns the total size (expressed in bytes) of the volume where the File object is stored.

    Returns Number

moveTo

  • moveTo(file: WAKFileInstance, overwrite?: Boolean): void
  • moveTo(file: String, overwrite?: Boolean): void
  • Moves the file to the specified destination.

    var myFile = new File( 'PROJECT/my-file.js' );
    myFile.create();
    myFile.moveTo( 'PROJECT/my-moved-file.js', yes );
    // myFile always references the "my-file.js" file
    // The referenced file did not change with the moveTo() action.
    console.log( myFile.path );
    warning

    After the moveTo() action, the file referenced is still the source file and not the destination file. Therefore, the referenced file does not exist anymore.

    Parameters

    • file: WAKFileInstance

      Destination file path

    • Optional overwrite: Boolean

      true if the file can be overwritten, false otherwise

    Returns void

  • Moves the file to the specified destination.

    var mySourceFile = new File( 'PROJECT/my-file.js' );
    var myDestinationFile = new File( 'PROJECT/my-moved-file.js' );
    // The file must exists to be renamed
    myFile.create();
    myFile.moveTo( myDestinationFile, yes );
    // myFile always references the "my-file.js" file
    // The referenced file did not change with the moveTo() action.
    console.log( myFile.path );
    // PROJECT/my-file.js
    warning

    After the moveTo() action, the file referenced is still the source file and not the destination file. Therefore, the referenced file does not exist anymore.

    Parameters

    • file: String

      Destination file path

    • Optional overwrite: Boolean

      true if the file can be overwritten, false otherwise

    Returns void

remove

  • remove(): Boolean
  • Removes the file from the disk.

    Returns Boolean

    true if the file is removed from disk, false otherwise.

setName

  • setName(name: String): Boolean
  • Rename the file on disk.

    var myFile = new File( 'PROJECT/my-file.js' );
    // The file must exists to be renamed
    myFile.create();
    // The destination file name must be free
    myFile.setName( 'my-renamed-file.js' );
    // myFile always references the "my-file.js" file
    // The referenced file did not change with the setName() action.
    console.log( myFile.path );
    // PROJECT/my-file.js
    warning

    The file must exist on disk to be renamed

    warning

    The file destination must be free

    throws

    An error if something goes wrong: file already exists, invalid name, ...

    Parameters

    • name: String

      New file name

    Returns Boolean

    true if the file is successfully renamed

slice

  • Creates a new blob by referencing the binary contents of the File to which it is applied, from start to end.

    Example 1: Slice a blob

    var myBlob = new Blob( 20 , 88, 'application/octet-stream' );
    console.log( myBlob.toString() );
    // XXXXXXXXXXXXXXXXXXXX
    var mySlicedBlob = myBlob.slice( 5, 10 );
    console.log( mySlicedBlob.toString() );
    // XXXXX

    Example 2: Slice a blob

    var myBlob = new Blob( 20 , 88, 'application/octet-stream' );
    console.log( myBlob.toString() );
    // XXXXXXXXXXXXXXXXXXXX
    var mySlicedBlob = myBlob.slice( 0, -5 );
    console.log( mySlicedBlob.toString() );
    // XXXXXXXXXXXXXXX

    Example 3: Slice a file

    var myFile = new File( 'PROJECT/bootstrap.js' );
    var myBlobSlice = myFile.slice( 0, 100 );
    console.log( myBlobSlice.toString() );

    Parameters

    • Optional start: Number

      (default: 0)

    • Optional end: Number

      (default: blob.size)

    • Optional mimeType: String

    Returns WAKBlobInstance

toBuffer

toString

  • toString(stringFormat?: String): String