New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

nexusdocs-client

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nexusdocs-client

Client SDK for nexusdocs-server

latest
Source
npmnpm
Version
0.3.4
Version published
Maintainers
1
Created
Source

nexusdocs-client

Client-SDK for nexusdocs-server

NexusDocs Documentation

Use

npm install nexusdocs-client

Modules

nexusdocs-client

Classes

Client

Class presenting NexusDocs client instance

Namespace

Class presenting NexusDocs namespace instance

nexusdocs-client

module.exports(options) ⇒ Client

Create a NexusDocs client instance

Kind: Exported function
See: new Client()

ParamTypeDescription
optionsServerOptionsServer options, see ServerOptions

Example
Create a client

const createClient = require('nexusdocs-client');

// Object style server options:
const client = createClient({
  hostname: '192.168.1.6',
  port: 4001,
  apiKey: 'MY_API_KEY',
  apiSecret: 'MY_API_SECRET',
});

// URL style server options:
const client = createClient('http://MY_API_KEY:MY_API_SECRET@192.168.1.6:4001/api');

Client

Class presenting NexusDocs client instance

Kind: global class

new Client(options)

Creates an instance of NDS Client.

ParamTypeDescription
optionsServerOptions | stringServer options, see ServerOptions

Example
You can pass a URL sting instead of a config object:

http://<clientKey>:<clientSecret>@<hostname>:<port><endPoint>

client.getNamespace(name, [options]) ⇒ Namespace

Get namespace instance

Kind: instance method of Client
Returns: Namespace - Namespace instance

ParamTypeDescription
namestringThe name
[options]objectAdditional options

Client~ServerOptions : object

Server options

Kind: inner typedef of Client
Properties

NameTypeDefaultDescription
clientKeystringNDS API key
clientSecretstringNDS API secret
[hostname]string"127.0.0.1"hostname
[secure]booleanfalseWhether to use HTTPS
[port]number4000Server Port
[endPoint]string"/api"API endpoint
[defaultUrlExpires]numberDefault expires seconds
[defaultRequestExpires]numberDefault expires seconds

Namespace

Class presenting NexusDocs namespace instance

Kind: global class

new Namespace(client, name, options)

Namespace Class constructor

ParamTypeDescription
clientClientNDS Client instance
namestringThe name of namespace
optionsobject

Example
Create a namespace instance

const namespace = client.getNamespace('a.name.space');

namespace.getUploadUrl([options]) ⇒ string

Get URL for upload

Kind: instance method of Namespace
Returns: string - URL for upload

ParamTypeDescription
[options]RequestOptionsAdditional options, see RequestOptions
[options.resumable]booleanIf upload with resumbable.js
[options.expires]dateTimestamp the Request will available before

namespace.getDownloadUrl(fileId, [options]) ⇒ string

Get file URL for view or download

Kind: instance method of Namespace
Returns: string - file URL

ParamTypeDescription
fileIdFileIdFile identifier, see FileId
[options]DownloadOptionsAdditional options, see DownloadOptions

namespace.getConvertedUrl(fileId, converting, [options]) ⇒ string

Get the converted file URL for view or download

Kind: instance method of Namespace
Returns: string - The converted file URL

ParamTypeDescription
fileIdFileIdFile identifier, see FileId
convertingConvertingOptionsConverting options, see ConvertingOptions
[options]DownloadOptionsAdditional options, see DownloadOptions

namespace.upload(Buffer|ReadableStream, [options]) ⇒ Promise

Upload file from Buffer, ReadableStream

Kind: instance method of Namespace
Fulfil: object File info when uploading is finished
Reject: any Request error

ParamTypeDescription
BufferReadableStreamdata
[options]UploadOptionsAdditional options, see UploadOptions

namespace.openUploadStream([options]) ⇒ WritableStream

Get upload stream

Kind: instance method of Namespace
Returns: WritableStream - Writable stream for upload

ParamTypeDescription
[options]UploadOptionsAdditional options, see UploadOptions
[options.stream]ReadableStreamProvide readable stream directly

namespace.uploadFromLocal(filePath, options) ⇒ Promise

Upload a file from local file-system

Kind: instance method of Namespace
Fulfil: FileInfo File info when uploading is finished
Reject: any Request error

ParamTypeDescription
filePathstringThe path of file will be uploaded
optionsUploadOptionsUpload options

namespace.openDownloadStream(fileId, [options]) ⇒ ReadableStream

Get a readable stream for download

Kind: instance method of Namespace
Returns: ReadableStream - - the readable stream

ParamTypeDescription
fileIdFileIdThe file needed to download later, see FileId
[options]RequestOptionsAdditional options, see RequestOptions

namespace.downloadToLocal(fileId, filePath, [options]) ⇒ Promise

Download a file to local file-system

Kind: instance method of Namespace
Fulfil: any Download finished

ParamTypeDescription
fileIdFileIdThe file id, see FileId
filePathstringThe path of file will be saved
[options]RequestOptionsAdditional options, see RequestOptions

namespace.getFileInfo(fileId) ⇒ Promise

Get file information

Kind: instance method of Namespace
Fulfil: FileInfo file information

ParamType
fileIdFileId

namespace.delete(fileId) ⇒ Promise

Delete a file on the server

Kind: instance method of Namespace
Fulfil: object When deletion is finished
Reject: any When a error occur

ParamTypeDescription
fileIdFileIdThe file to be deleted, see FileId

namespace.truncate() ⇒ Promise

Delete all files in this namespace

Kind: instance method of Namespace

namespace.createArchive(files) ⇒ Promise

Create an archive

Kind: instance method of Namespace

ParamTypeDescription
filesArray.<FileId>file id array

namespace.getArchiveUrl(files, options)

Archive files then return download URL

Kind: instance method of Namespace

ParamTypeDescription
filesArray.<FileId>file id array, see FileId
optionsRequestOptionsRequestOptions, see RequestOptions

Namespace~RequestOptions : object

Request options for request, some properties are added for additional use, see specified method

Kind: inner typedef of Namespace
Properties

NameTypeDescription
methodstringHTTP method of the request
urlstringPath of the request, or full url
[body]stringEntire body for PATCH, PUT, POST or DELETE, json must be true and only plain object is allowed
[json]booleanSet to true when providing body
[expires]number | dateExpires time in second, timestamp or Date object, the request will be invalid after this timestamp
[signature]objectAdditional signature data besides method, url, expires

Namespace~UploadOptions : object

Upload request options

Kind: inner typedef of Namespace
Extends: RequestOptions
Properties

NameTypeDescription
[fileId]FileIdSpecify fileId, see FileId
[filename]stringProvide filename
[md5]stringMD5 hash of the file if available
[contentType]stringProvide content-type for download
[knownLength]numberProvide stream total length if available

Namespace~DownloadOptions : object

Download options

Kind: inner typedef of Namespace
Extends: RequestOptions
Properties

NameTypeDefaultDescription
[origin]booleanfalseDownload from the origin provider
[download]booleanfalseDownload with the original filename
[filename]stringDownload with new filename, this will set contentType & contentDisposition
[response]objectOverwrite response header
[response.contentType]stringOverwrite Content-Type
[response.contentDisposition]stringOverwrite Content-Disposition

Namespace~FileId : string

File identifier

Kind: inner typedef of Namespace
Example

Example file id: `e5ac71cf-a0f0-46b5-9070-268ae97bb769`

Namespace~ImageInfo : object

Image file info

Kind: inner typedef of Namespace
Properties

NameTypeDescription
widthnumberImage width
heightnumberImage height
typenumberImage type, e.g. jpeg, png, gif
thumbnailUrlstringImage thumbnail data-url

Namespace~ZipFileEntry : object

Zip file entry

Kind: inner typedef of Namespace
Properties

NameTypeDescription
pathstringRelative path to zip archive
sizenumberStored size
lastModifieddateLast modified date

Namespace~ZipInfo : object

Zip file info

Kind: inner typedef of Namespace
Properties

NameTypeDescription
entriesArray.<ZipFileEntry>files

Namespace~FileInfo : object

File information

Kind: inner typedef of Namespace
Properties

NameTypeDescription
namespacestringNamespace file is stored in
md5stringMD5 hash string
contentTypestringFile content type
sizenumberFile total length
metadataobjectAdditional information
[metadata.image]ImageInfoMetadata for image files
[metadata.zip]ZipInfoZip file entries

Namespace~ConvertingOptions : object

File converting options

Kind: inner typedef of Namespace
Properties

NameTypeDescription
formatstringThe output format, documents: pdf, image: gif, jpeg, png, webp, tiff
[resize]stringFor image, resize the image <width>x<height>{%}{@}{!}{<}{>} please check GraphicsMagick. notice: only {!}{>}{^} are available when the server is using ImageSharpConverter
[rotate]string | numberFor image, rotate the image by angle {auto}{90}{180}{270}, if auto is set, the angle will be detected by gravity from EXIF
[quality]numberForimage, set the output image quality 0 - 100, available for format jpeg, tiff, webp

Example
Get a thumbnail of size 32px

{
  format: 'jpeg',
  resize: '32x32',
  rotate: 'auto'
}

Example
Get a pdf version of a document

{
  format: 'pdf',
}

License

MIT

Keywords

storage

FAQs

Package last updated on 08 Sep 2020

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