Socket
Book a DemoInstallSign in
Socket

linshare-api-client

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linshare-api-client

JS library for Linshare APIs

0.0.21
latest
Source
npmnpm
Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

linshare-api-client

JS library for Linshare APIs

Installation

NPM:

npm install linagora/linshare-api-client

Bower:

bower install linshare-api-client

Usage

const { Client } = require('linshare-api-client');

const client = new Client({
  baseUrl: 'https://files.linshare.local/linshare/webservice/rest',
  auth: {
    type: 'basic',
    username: '<username>',
    password: '<password>'
    // OR by JWT
    // type: 'jwt',
    // token: '<token>'
  }
});

client.user.workgroup.list()
  .then(data => console.log(data))
  .catch(err => console.error(err));

On browser:

const Client = window.LinshareApiClient.Client;

...

APIs

User API

Authentication

Get authorized user

client.user.authentication.authorized().then(...)

Workgroup

Create document in a node of work group from URL

client.user.workgroup.createDocumentFromUrl('work-group-uuid', documentInfo, options)
  .then(...)
  • documentInfo: an object contains
    • url (required): file url
    • fileName (optional): file name
    • size (optional): file size
  • options (optional): { parent: 'parentNodeUuid', async: true/false, strict: true/false }

Delete a node in workgroup

client.user.workgroup.deleteNode('work-group-uuid', 'node-uuid')
  .then(...)

List workgroups

client.user.workgroup.list().then(...)

List nodes in a workgroup

client.user.workgroup.listNodes(workgroupUuid, options).then(...)
  • options (optional): { parent: 'parentNodeUuid', type: 'FOLDER | DOCUMENT' }

Update a node in workgroup

client.user.workgroup.updateNode('work-group-uuid', 'node-uuid', modified)
  .then(...)

Documents

Get a document

client.user.documents.get('documentUuid').then(...)

List documents

client.user.documents.list().then(...)

Create a document

Upload a file to My space

var options = {
  async: false,
  onUploadProgress: function(progressEvent) {
    var processedPercent = Math.round((progressEvent.loaded * 100) / progressEvent.total);
    console.log('Uploading...', processedPercent);
  }
};
var formData = new FormData();

formData.append('file', file);
formData.append('filesize', fileSize);

client.user.documents.create(formData, options).then(...)

Share

Share documents

client.user.shares.shareDocuments({
  documents: ['documentUuid1', 'documentUuid2'],
  recipients: [{
    mail: 'user1@domain.com'
  }, {
    mail: 'user2@domain.com'
  }]
}).then(...)

Download document

Accept different response type with default value being blob. You are advised to use different response types based on running environment:

  • blob is for browser
  • arrayBuffer is for nodejs environment
client.user.workgroup.downloadDocument('work-group-uuid', 'node-uuid', { responseType: 'blob' })
  .then(function(blob) {
    const file = new File([blob], 'documentname');
  })

Get a node in workgroup

client.user.workgroup.getNode('work-group-uuid', 'node-uuid')
  .then(...)

Shared space nodes

Get a member of a shared space node

client.user.sharedSpaceNodes.findMemberByAccountUuid('shared-space-node-uuid', 'member-uuid')
  .then(...)

Shared space roles

Get a shared space role by uuid

client.user.sharedSpaceRoles.findAllPermissions('shared-space-role-uuid')
  .then(...)

Release

Assume that you are in master branch and you have write access to the origin remote, type the following command to release a new version:

./scripts/release.sh x.y.z

In case your Git remote is NOT origin:

./scripts/release.sh x.y.z my-remote

Licence

Affero GPL v3

Keywords

linshare

FAQs

Package last updated on 02 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.