FileServer

FileServer

Facilitates interaction with the wallet server.

Constructor

new FileServer(sdk, serverUrl, opts)

Create a new wallet server instance.

Source:
Parameters:
Name Type Description
sdk ShelfNetwork

Parent SDK instance.

serverUrl string

wallet server URL.

opts Object
Name Type Attributes Default Description
allowHttp boolean <optional>

Allow connecting to http servers, default: false. This must be set to false in production deployments!

proxy Object <optional>

Proxy configuration. Look axios docs for more info

httpBasicAuth Object <optional>

HTTP basic auth credentials. Look axios docs for more info.

customHeaders Object <optional>

Custom headers for request.

withCredentials boolean <optional>

Indicates whether or not cross-site Access-Control requests should be made using credentials.

responseType string <optional>
'json'

Indicates the type of data that the server will respond with options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'.

Methods

get(fileId) → {Promise.<JsonApiResponse>}

Get a file by ID.

Source:
Parameters:
Name Type Description
fileId string

File ID.

Returns:
Type:
Promise.<JsonApiResponse>

Payment server response.

getPage(queryopt) → {Promise.<JsonApiResponse>}

Get personal files.

Source:
Parameters:
Name Type Attributes Description
query object <optional>

Request options.

Name Type Attributes Description
in Array.<string> <optional>

Array of document id's.

page.number Number <optional>

Page number.

page.size Number <optional>

Page size.

Returns:
Type:
Promise.<JsonApiResponse>

Cart response.

upload(file, opts) → {Promise.<JsonApiResponse>}

Uploads a file to the storage server.

Source:
Parameters:
Name Type Description
file File | Blob | ReadableStream

A file to upload.

opts object

Document options.

Name Type Attributes Default Description
accessType string <optional>
'public'

Document access type. 'private' or 'public'

owners Array.<string> <optional>
[]

Account IDs of the document owners

expires string <optional>

Document expiration time.

Returns:
Type:
Promise.<JsonApiResponse>

Payment server response.