Browse SDKs · React Native
Platform
SDKsReact Native

Create file message from file

Construct a file message from a local filesystem path using the OpenIM React Native SDK.

Copy

Construct a file message from a local file on the device filesystem:

const message = await OpenIMSDK.createFileMessageFromFullPath({
  filePath,
  fileName: 'product-specification.pdf',
});

Parameters

ParameterTypeRequiredDescription
filePathstringYesAbsolute local filesystem path to the target file.
fileNamestringYesDisplay filename presented in the message view.

Return value

A resolved Promise returns the initialized MessageItem object with file metadata populated in fileElem.

This method builds the message structure strictly in client memory; it does not dispatch messages to the server or trigger lifecycle events. After initialization, invoke Send message to deliver it to a conversation; the SDK automatically uploads the local file during transmission.