Class: Files

Files(helperFile)

The Files class, has all the methods for your ownCloud files management.

Supported Methods are:
  • Files Management
    • list
    • getFileContents
    • putFileContents
    • mkdir
    • createFolder
    • delete
    • fileInfo
    • getDirectoryAsZip
    • putFile
    • putDirectory
    • move
    • copy

Constructor

new Files(helperFile)

Parameters:
Name Type Description
helperFile helpers instance of the helpers class
Version:
  • 1.0.0
Author:
  • Noveen Sachdeva
Source:

Methods

copy(source, target) → {Promise.<status>|Promise.<error>}

Copies a remote file or directory
Parameters:
Name Type Description
source string initial path of file/folder
target string path where to copy file/folder finally
Source:
Returns:
  • boolean: whether the operation was successful
    Type
    Promise.<status>
  • string: error message, if any.
    Type
    Promise.<error>

createFolder(path) → {Promise.<status>|Promise.<error>}

Creates a remote directory
Parameters:
Name Type Description
path string path of the folder to be created at OC instance
Source:
Returns:
  • boolean: wether the operation was successful
    Type
    Promise.<status>
  • string: error message, if any.
    Type
    Promise.<error>

delete(remotePath) → {Promise.<status>|Promise.<error>}

Deletes a remote file or directory
Parameters:
Name Type Description
remotePath string path of the file/folder at OC instance
Source:
Returns:
  • boolean: wether the operation was successful
    Type
    Promise.<status>
  • string: error message, if any.
    Type
    Promise.<error>

favorite(path, value) → {Promise.<status>|Promise.<error>}

Mark a remote file or directory as favorite
Parameters:
Name Type Description
path string path of file/folder
value boolean Add or remove the favorite marker of a file/folder
Source:
Returns:
  • boolean: whether the operation was successful
    Type
    Promise.<status>
  • string: error message, if any.
    Type
    Promise.<error>

fileInfo(path, properties) → {Promise.<fileInfo>|Promise.<error>}

Returns the file info for the given remote file
Parameters:
Name Type Description
path string path of the file/folder at OC instance
properties Object.<string, string> WebDAV properties
Source:
Returns:
  • object: instance of class fileInfo
    Type
    Promise.<fileInfo>
  • string: error message, if any.
    Type
    Promise.<error>

getFileContents(path) → {Promise.<contents>|Promise.<error>}

Returns the contents of a remote file
Parameters:
Name Type Description
path string path of the remote file at OC instance
Source:
Returns:
  • string: contents of file
    Type
    Promise.<contents>
  • string: error message, if any.
    Type
    Promise.<error>

getFileUrl(path) → {string}

Returns the url of a remote file
Parameters:
Name Type Description
path string path of the remote file at OC instance
Source:
Returns:
Url of the remore file
Type
string

list(path, depth, properties) → {Promise.<fileInfo>|Promise.<error>}

Returns the listing/contents of the given remote directory
Parameters:
Name Type Description
path string path of the file/folder at OC instance
depth string 0: only file/folder, 1: upto 1 depth, infinity: infinite depth
properties array Array[string] with dav properties to be requested
Source:
Returns:
  • Array[objects]: each object is an instance of class fileInfo
    Type
    Promise.<fileInfo>
  • string: error message, if any.
    Type
    Promise.<error>

mkdir(path) → {Promise.<status>|Promise.<error>}

Creates a remote directory
Parameters:
Name Type Description
path string path of the folder to be created at OC instance
Source:
Returns:
  • boolean: whether the operation was successful
    Type
    Promise.<status>
  • string: error message, if any.
    Type
    Promise.<error>

move(source, target) → {Promise.<status>|Promise.<error>}

Moves a remote file or directory
Parameters:
Name Type Description
source string initial path of file/folder
target string path where to move file/folder finally
Source:
Returns:
  • boolean: whether the operation was successful
    Type
    Promise.<status>
  • string: error message, if any.
    Type
    Promise.<error>

putFileContents(path, content) → {Promise.<status>|Promise.<error>}

Write data into a remote file
Parameters:
Name Type Description
path string path of the file at OC instance
content string content to be put
Source:
Returns:
  • boolean: whether the operation was successful
    Type
    Promise.<status>
  • string: error message, if any.
    Type
    Promise.<error>

recursiveMkdir(array) → {Promise.<status>|Promise.<error>}

Helper for putDirectory This function first makes all the directories required
Parameters:
Name Type Description
array object file list (ls -R) of the directory to be put
Source:
Returns:
  • boolean: wether mkdir was successful
    Type
    Promise.<status>
  • string: error message, if any.
    Type
    Promise.<error>