new FileTransfer()
Methods
-
abort(fileConfig)
-
Aborts a single file transfer session using the fileTransferId that was given in the fileConfig.
Parameters:
Name Type Description fileConfig
FileConfig the fileConfig that represents the file transfer session to be aborted. If not provided, abort all file transfer sessions.
-
abort(fileConfigs)
-
Aborts multiple file transfer sessions using the fileTransferIds that are given in the fileConfigs array.
Parameters:
Name Type Description fileConfigs
Array the fileConfigs array that represents the file transfer sessions to be aborted. if not provided, abort all file transfer sessions.
-
accept(fileConfig, extHeaders)
-
Accepts a single file transfer request with the given fileConfig, or not, providing that means completely accepting the request.
Parameters:
Name Type Description fileConfig
FileConfig Optional: the accepted fileConfig.
extHeaders
Object Optional: extension headers.
-
accept(fileConfigs, extHeaders)
-
Accepts multiple files transfer request with the given fileConfigs, or not, providing that means completely accept the request.
Parameters:
Name Type Description fileConfigs
Array Optional: an array of fileConfig.
extHeaders
JSON Optional: extension headers.
-
addParticipants(participants)
-
Add participants to the created FileTransfer object. This function is used when the target is a conference address and the client wants to transfer files to those participants.
Parameters:
Name Type Description participants
Array an array of participants name.
-
decline(code, reason, extHeaders)
-
Declines the file transfer request with a given code and reason.
Parameters:
Name Type Description code
Number the specified error code.
reason
String the specified error reason.
extHeaders
JSON extension headers.
-
getFileConfigs() → {Array}
-
Gets the configuration of FileTransfer.
Returns:
fileConfigs - the fileConfigs array that represents the file transfer.
- Type
- Array
-
getInitiator()
-
Gets initiator of the FileTransfer
-
getState() → {wsc.CallState}
-
Gets the signalling state of FileTransfer.
Returns:
state - The signalling state of the FileTransfer.
- Type
- wsc.CallState
-
getTarget()
-
Gets target of the FileTransfer.
-
setChunkSize(size)
-
Sets the trunk size.
Parameters:
Name Type Description size
Number the trunk size in bytes; default value is 2048.
-
setSecure(isSecure)
-
Sets the transport layer to be secure or not.
Parameters:
Name Type Description isSecure
Boolean Default value is true.
-
start(fileConfig, extHeaders)
-
Starts a file transfer with single file. The default operation is to push the file to target. If fileConfig.props.direction is set to 'receive', the operation is to pull file from target. After invoking this method, the SDK will set the 'fileTransferId' to the fileConfig object.
Parameters:
Name Type Description fileConfig
FileConfig the configuration for the transferring file.
extHeaders
JSON Optional: extension headers.
-
start(fileConfigs, extHeaders)
-
Starts a file transfer with multiple files. The default operation is to push file to target. If fileConfig.props.direction is set to 'receive', the operation is to pull file from target. After invoking this method, the SDK will set the 'fileTransferId' to each fileConfig object.
Parameters:
Name Type Description fileConfigs
Array An array of fileConfig.
extHeaders
Object Optional: extension headers.
Events
-
onConnectionStateChange
-
callback function for the file transfer connection state changes.
Parameters:
Name Type Description state
ConnectionState the current file transfer connection state.
-
onFileData
-
callback function for incoming file transfer data.
Parameters:
Name Type Description data
FileData The received file data.
-
onFileTransferFailure
-
Callback function for file transfer failure.
Parameters:
Name Type Description fileTransferId
String the file transfer ID.
status
Number the status code.
reason
String the reason description.
-
onFileTransferSuccess
-
Callback function for file transfer success.
Parameters:
Name Type Description fileTransferId
String the file transfer ID.
-
onMessage
-
For extensibility - Processes the received JSON message between the client and WebRTC Session Controller server.
An application can override this method to handle the JSON message directly.Parameters:
Name Type Description msg
Object the JSON message between client and WebRTC Session Controller server.
-
onProgress
-
Callback function for sending file progress data.
Parameters:
Name Type Description progress
FileProgressData The progress data.
-
onStateChange
-
callback function for FileTransfer signalling state changes.
Parameters:
Name Type Description state
wsc.CallState An instance of CallState object.
extHeaders
JSON Optional. Extension headers.