File Exchange

Introduction

The File Exchange container allows Trust1Connector to upload or download files from the filesystem to the requesting party. In order to be able to access the file system, a separate file_exchange consent is required.

The File Exchange container provides the following functionalities:

  • selecting a folder to use (using system folder selection mechanism)

  • listing files in selected folder

  • downloading a provided file into selected folder

  • uploading a file from the selected folder

Available Functions

The following functions are available in the T1C-JS library:

JavaScript API

Function

Input

Output

Description

downloadFile

path, file, fileName

N/A

Creates a file named fileName at the path location, with file contents file

listFiles

{ path, extensions }

list of files in directory

Returns a list of all files in the path directory that have an extension included in the extensions array

setFolder

N/A

path of selected directory

Triggers a system file selection dialog that allows the user to select a directory. The selected directory is returned as the response

uploadFile

path

fileBuffer

Will retrieve the file located at path and return it as a fileBuffer

Detailed Function Overview

downloadFile

Downloads a provided file(Buffer) into the provided directory.

Interface

downloadFile(path: string, file: ArrayBuffer, fileName: string)

Parameters

  • path: location for the newly created file

  • file: ArrayBuffer containing binary data to be put in the file

  • fileName: name to be given to the file

Output

{
    data: string // absolute path of the newly created file
    success: boolean
}

listFiles

Returns a list of files in the selected directory.

Interface

listFiles({ path: string, extensions: string[] }, callback: (error, data))

Parameters

  • dataObject containing two config parameters:

    • path: directory to list

    • extensions: array of file extensions to be included in the list

Output

{
    data: [{
        extension: string,
        last_modification_time: string,
        name: string,
        path: string,
        size: number
    }],
    success: boolean
}

setFolder

Triggers system dialog to select a folder

Interface

setFolder(callback?: (error, data))

Parameters

  • none

Output

{
    data: string // path of the selected folder
    success: boolean
}

uploadFile

Uploads the file located at path to the requesting user.

Interface

uploadFile(path: string)

Parameters

  • feature: absolute path to the requested file

Output

fileBuffer

Last updated