SDKsReact Native
Create file message from URL
Construct a file message using pre-uploaded remote file metadata and URL using the OpenIM React Native SDK.
Construct a file message using remote resource metadata from a pre-uploaded file:
const message = await OpenIMSDK.createFileMessageByURL({
filePath: '',
fileName: 'product-specification.pdf',
uuid: 'file-001',
sourceUrl: 'https://www.example.com/product-specification.pdf',
fileSize: 256000,
fileType: 'application/pdf',
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | string | Yes | Local filesystem path; pass empty string "" when using remote-only assets. |
fileName | string | Yes | Display filename presented in the message view. |
uuid | string | Yes | Unique resource identifier for the file. |
sourceUrl | string | Yes | Accessible remote URL where the file is hosted. |
fileSize | number | Yes | Size of the file in bytes. |
fileType | string | No | File MIME type (e.g. 'application/pdf'). |
Return value
A resolved Promise returns the initialized MessageItem object with remote file properties stored 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 uploaded media message to deliver it to a conversation without repeating file uploads.
Was this page helpful?