0.1.11 • Published 2 years ago

@667/js-owncloud-client v0.1.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Build Status Dependencies Status devDependencies Status

The main purpose of this form was to update the deps (mainly request which is now deprecated) and axios, axios-retry, and form-data basically take the place of the request package. Further the node-lts branch is the primary branch of concern as owncloud sdk in general is designed to run in the browser not node.

Install

$ npm install js-owncloud-client

Usage

Node.JS

var owncloud = require('js-owncloud-client');
var oc = new owncloud('*owncloud instance URL*');

// Login
oc.login('username', 'password').then(status => {
    // STUFF
}).catch(error => {
    // HANDLE ERROR
});

// Share File With Link
oc.shares.shareFileWithLink('linkToYourFile').then(shareInfo => {
    console.log("Link is : " + shareInfo.getLink());
}).catch(error => {
    // HANDLE ERROR
});

// List all files
oc.files.list('/path/to/file/folder').then(files => {
    console.log(files);
}).catch(error => {
    console.log(error);
});

Browser

<script type="text/javascript" src="./js-owncloud-client/browser/owncloud.js"></script>

<script type="text/javascript">
  // var oc is global
  oc.setInstance('*owncloud instance URL*');

  // Login
  oc.login('username', 'password').then(status => {
    window.alert(status);
  }).catch(error => {
    window.alert(error);
  });

  // Share File With Link
  oc.shares.shareFileWithLink('linkToYourFile').then(shareInfo => {
      window.alert("Link is : " + shareInfo.getLink());
  }).catch(error => {
      window.alert(error);
  });

  // List all files
  oc.files.list('/path/to/file/folder').then(files => {
      console.log(files);
  }).catch(error => {
      console.log(error);
  });
</script>

Example Projects

Node.JS Based

Browser Based

A sample text-file saving and retreiving static web app which uses this library: link

All Methods Available

General

var owncloud = require('js-owncloud-client');
var oc = new owncloud('*owncloud instance URL*');
MethodCode
setInstanceoc.setInstance(instance)
loginoc.login(username, password)
getConfigoc.getConfig()
getVersionoc.getVersion()
getCapabilitiesoc.getCapabilities()

Files Management

var owncloud = require('js-owncloud-client');
var oc = new owncloud('*owncloud instance URL*');
MethodCode
listoc.files.list(/path/to/file/folder, depth)
getFileContentsoc.files.getFileContents(path/to/file/folder)
putFileContentsoc.files.putFileContents(path/to/file, contents)
mkdiroc.files.mkdir(path/to/folder)
createFolderoc.files.createFolder(path/to/folder)
deleteoc.files.delete(path/to/file/folder)
fileInfooc.files.fileInfo(path/to/file/folder)
getFileoc.files.getFile(remotePath, localPath)
getDirectoryAsZipoc.files.getDirectoryAsZip(remotePath, localPath)
putFileoc.files.putFile(remotePath, localPath)
putDirectoryoc.files.putDirectory(remotePath, localPath)
moveoc.files.move(source, target)
copyoc.files.copy(source, target)

Apps Management

var owncloud = require('js-owncloud-client');
var oc = new owncloud('*owncloud instance URL*');
MethodCode
getAppsoc.apps.getApps()
getAttributeoc.apps.getAttribute(app, key)
setAttributeoc.apps.setAttribute(app, key, value)
deleteAttributeoc.apps.deleteAttribute(app, key)
enableAppoc.apps.enableApp(appName)
disableAppoc.apps.disableApp(appName)

Group Management

var owncloud = require('js-owncloud-client');
var oc = new owncloud('*owncloud instance URL*');
MethodCode
createGroupoc.groups.createGroup(groupName)
deleteGroupoc.groups.deleteGroup(groupName)
getGroupsoc.groups.getGroups()
getGroupMembersoc.groups.getGroupMembers(groupName)
groupExistsoc.groups.groupExists(groupName)

Share Management

var owncloud = require('js-owncloud-client');
var oc = new owncloud('*owncloud instance URL*');
MethodCode
shareFileWithLinkoc.shares.shareFileWithLink(path, {perms: perms, publicUpload: publicUpload, password: password})
updateShareoc.shares.updateShare(shareId, {perms: perms, publicUpload: publicUpload, password: password})
shareFileWithUseroc.shares.shareFileWithUser(path, username, {perms: perms, remoteUser: remoteUser })
shareFileWithGroupoc.shares.shareFileWithGroup(path, groupname, {perms: perms })
getSharesoc.shares.getShares()
isSharedoc.shares.isShared(path/to/file/folder)
getShareoc.shares.getShare(shareId)
listOpenRemoteShareoc.shares.listOpenRemoteShare()
acceptRemoteShareoc.shares.acceptRemoteShare(shareId)
declineRemoteShareoc.shares.declineRemoteShare(shareId)
deleteShareoc.shares.deleteShare(shareId)

User Management

var owncloud = require('js-owncloud-client');
var oc = new owncloud('*owncloud instance URL*');
MethodCode
createUseroc.users.createUser(username, password)
deleteUseroc.users.deleteUser(username)
searchUsersoc.users.searchUsers(searchKey)
userExistsoc.users.userExists(username)
getUsersoc.users.getUsers()
setUserAttributeoc.users.setUserAttribute(username, key, value)
addUserToGroupoc.users.addUserToGroup(username, groupName)
getUserGroupsoc.users.getUserGroups(username)
userIsInGroupoc.users.userIsInGroup(username, groupName)
getUseroc.users.getUser(username)
removeUserFromGroupoc.users.removeUserFromGroup(username, groupName)
addUserToSubadminGroupoc.users.addUserToSubadminGroup(username, groupName)
getUserSubadminGroupsoc.users.getUserSubadminGroups(username)
userIsInSubadminGroupoc.users.userIsInSubadminGroup(username, groupName)

Building the Documentation

Swagger Documentation

Stuck? Just type this to see all the above available methods live in action in your browser!

$ cd node_modules/js-owncloud-client/
$ make swagger

If you open the link showed by running the above command, you will see something like this :

Here, you can click on any method and type in values, to experiment with the methods in the browser itself! Now isn't that cool? :wink:

JSDocs

To build the jsdocs, type this command and follow the instructions on the terminal :

$ cd node_modules/js-owncloud-client/
$ make jsdocs

Unit tests

The following command will run all unit tests. Before running the command, make sure you have edited the owncloud/test/config.json file accordingly.

$ cd node_modules/js-owncloud-client/
$ make test

Team

Noveen Sachdeva         Vincent Petry Noveen Sachdeva             Vincent Petry

GSoC'17

0.1.11

2 years ago

0.1.10

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3-v3

3 years ago

0.1.3-v2

3 years ago

0.1.3-v1

3 years ago

0.1.3

3 years ago