Skip Navigation

METHOD_PC_FileUpload

This method uploads a file to a group discussion. Before users can upload a file to a group discussion, users must join the the group discussion. This method requires 
BEMS
 2.8 or later. 
The following features are not supported with this method: 
  • Resumable uploads  
  • Embedded file messages: Users can add text, add a file and then add more text. This is sent as a single message.
  • Icons and thumbnails are not available for the uploaded files. 
For code sample information on how to upload in a group discussion, visit msdn.microsoft.com to read 
How to: Upload and download files to and from a Persistent Chat room
The following table describes the parameters that you can include in this method.
Parameter
Type
Required
Description
roomId
String
This parameter specifies the group discussion ID to upload the file to.
fileName
String
This parameter specifies the name of the file to upload to the group discussion.
Group discussion messages can include one or more embedded file links and use the following format: {{file:
file-name
:
file-path
:
file-size
}}
fileRequestId
String
This parameter specifies the ID of the file to upload. The fileRequestID parameter allows the API call to correlate the request and response notifications. All notifications related to the file upload request include this parameter.
percentDone
Number
This parameter specifies the percent of the file that is uploaded to 
BEMS
.

Code sample 

The following example sends a request to 
BEMS
 to upload a file to a group discussion.
REST call URL: https://SERVER:8080/GaslampService/file/pc/ROOM-ID/FILE-NAME?fileRequestId=FILE-REQUEST-ID Verb: PUT HEADERS: Cookie:sessionId=...(text sample?) Accept:application/json X-User-Agent:<
iOS or Android
>
If the request fails, an appropriate error code and response body is returned that includes the file request ID.
HTTP/1.1 200 OK
BEMS
 sends the following notification to the 
BlackBerry Connect
 app and uploads the file to the group discussion. 
{ "id":"c5", "error":null, "result": { State: PROGRESS "data": { "method":"pc.FileUpload", "fileName":"Latest instructions", "roomId":"ma-chan://gems.example.com/25ac15e7-9bff-4e78-9261-6e08aa43231e", "percentDone":"75" } }, "jsonrpc":"2.0" }
If file icons, thumbnails, and picture files are made available by the instant messaging server, the icon appears in a JPEG format embedded inside of a chat message and uses the format {{picture:PICTURE-CONTENTS}}. Where PICTURE-CONTENTS is byte content as a hex string (for example, {{picture:FFD8FFE0...}} is a picture that starts with bytes 0xFF, 0xD8, 0xFF, 0xE0). If a picture is associated with a file (for example, a thumbnail or an icon), then the picture content follows immediately after the file link.