Skip to content

FileStore

Jayesh Choudhary edited this page Mar 20, 2019 · 1 revision

FileStore

Kind: global class

new FileStore(appId, url, options)

Create an instance of the FileStore Interface.

Param Type
appId string
url string
options Object

fileStore.uploadFile(path, file) ⇒ Promise

Uploads the given file at given path.

Kind: instance method of FileStore
Returns: Promise - Returns a promise containing response from server.

Param Type
path string
file file

Example

const fileInput = document.querySelector('#your-file-input');
api.FileStore().uploadFile("/some-path", fileInput.files[0]).then(res => {
  if (res.status === 200) {
    console.log("File uploaded successfully");
  }
})

fileStore.createFolder(path, name) ⇒ Promise

Creates a folder with given name at given path.

Kind: instance method of FileStore
Returns: Promise - Returns a promise containing response from server.

Param Type
path string
name string

Example

api.FileStore().createFolder("/some-path", "my-folder").then(res => {
  if (res.status === 200) {
    console.log("Folder created successfully");
  }
})

fileStore.listFiles(path) ⇒ Promise

Returns list of files within a directory.

Kind: instance method of FileStore
Returns: Promise - Returns a promise containing response from server.

Param Type
path string

Example

api.FileStore().listFiles("/some-path").then(res => ...)

fileStore.delete(path) ⇒ Promise

Deletes a file / folder at given path.

Kind: instance method of FileStore
Returns: Promise - Returns a promise containing response from server.

Param Type
path string

Example

api.FileStore().delete("/some-path").then(res => {
  if (res.status === 200) {
    console.log("Deleted successfully");
  }
})