METHOD_ReceiveFile

This method receives a file from the sender in a one-to-one chat.

The following features are not supported:
  • Resumable downloads

The following table lists the parameters that you can include in this method.

Parameter

Type

Required

Description

chatId

String

√

This parameter specifies the ID of the chat from which to download the file.

fileId

String

√

This parameter specifies the file ID created by the BlackBerry Connect client for the file.

fileName

String

√

This parameter specifies the name of the file to send.

fileSize

Long

√

This parameter specifies the size of the file to send.

percentDone

Number

√

This parameter provides the percentage of the file that is downloaded to BEMS.

Code example

The following example sends a request to BEMS for the recipient to receive the file from the one-to-one chat.

REST call URL:https://SERVER:8080/GaslampService/file/im/Contact-ID/FILE-NAME/FileSize?fileId=FILE-REQUEST-ID
Verb:GET
HEADERS: 
Cookie:sessionId=... 
Accept:application/json
X-User-Agent:<iOS or Android>

If the request is successful, BEMS sends the following response. The response body is the file contents.

HTTP/1.1 200 OK

The following example sends a request to BEMS that the recipient receives a file from "user1" in the chat.

{
 "method":"ReceiveFile",
 "params":
   {
    "contactId":"user1@example.com",
    "fileName":"MyFile.txt",
    "fileSize":1000000
   },
 "id":"c5",
 "jsonrpc":"2.0"
}

BEMS sends the following notification to the BlackBerry Connect app to receive the file. The file receive states are Processing > Progress > Complete. The receive includes a percentage of the file received that has completed.

{   
  "id":"c5", 
  "error":null,
  "result": 
  { 
   State: PROGRESS
   "data": 
    { 
      "method":"METHOD_ReceiveFile", 
      "fileName":"MyFile.txt",
      "percentDone":"75"
    } 
 }, 
 "jsonrpc":"2.0"
}