FANDOM


The File API Edit

The File API gives applications access to using the Multiplex file system. To get access, the "file" permission needs to be specified in the application manifest.

Usage Edit

To start using the file API, create a new file object by calling "var file = System.file(somePath);".

If you need to access functionality which requries metadata access, you need to call file.open(). This method takes a callback function that is triggered when the file is properly opened. Functionality which requries this includes streaming, metadata and listDirectory.

If you do not need this functionality, you can read and write directly on the file object.

API Overview Edit

Attributes Edit

Name Type Description
CloudFile.name string Name of the file, including extension
CloudFile.path string Absolute file path
CloudFile.service string file service descriptor (Dropbox, Drive, etc)
CloudFile.localPath string file path relative to the service
CloudFile.isDir boolean Does the file describe a directory
CloudFile.url string Virtual Url to reference data from this CloudFile. This attribute only exists if getUrl was called.

Methods Edit

Function Parameters Returns Description
System.file
  1. String path
  2. String path relative
CloudFile Object Creates a CloudFile Object
CloudFile.open
  1. function Callback(success)
- Opens this CloudFile, and grabs all necessary metadata
CloudFile.close - - Closes the CloudFile Object and releases the held resources
CloudFile.read
  1. function Callback(data)
- Reads data from the file system
CloudFile.write
  1. uint8Array data
  2. function Callback(success)
- Writes data to the file system
CloudFile.make
  1. function Callback(success)
- Makes sure the file exists
CloudFile.exists
  1. function Callback(exists)
- Checks if this file exists
CloudFile.delete
  1. function Callback(success)
Delete the CloudFile
CloudFile.stream
  1. number chunkSize
  2. function onChunk(data)
  3. function onStreamEnded
Future: Stream Control Object Establishes a chunked streaming session
CloudFile.getMetadata - Object
CloudFile.listDirectory - Array CloudFile Object List all files in this directory.
CloudFile.getFileType - string Gets the file extension.
CloudFile.getMime - string Gets the mime
CloudFile.getParent - CloudFile Object Gets the CloudFiles parent CloudFile.
CloudFile.zip
  1. function Callback(zipdata)
uint8Array
CloudFile.download - - Download this CloudFile Object to the clients computer.
CloudFile.upload - - Request a file from the clients computer to be upload to this CloudFile Object
CloudFile.getUrl
  1. function Callback(url)
- Creates a virtual Url to reference data from this CloudFile, useful when working with older libraries.
CloudFile.supportedOperations - Object Returns a object specifying supported operations. Read/Write etc.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.