SDKsReact Native
Create a file message from a URL
OpenIM React Native SDK guide for create a file message from a url.
Use createFileMessageByURL() to create a message from uploaded file resource information.
const message = await OpenIMSDK.createFileMessageByURL({
filePath: '',
fileName: 'product-guide.pdf',
uuid: 'file-001',
sourceUrl: 'https://www.example.com/product-guide.pdf',
fileSize: 256000,
fileType: 'application/pdf',
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | string | Yes | Local file path. Pass an empty string when only a remote resource is available. |
fileName | string | Yes | File name shown to recipients. |
uuid | string | Yes | File resource ID. |
sourceUrl | string | Yes | URL of the uploaded file. |
fileSize | number | Yes | File size in bytes. |
fileType | string | No | File type. |
The call returns a MessageItem ready to send. Use the actual upload result for resource information, then use Send an uploaded media message.
Was this page helpful?