SDKsReact Native
使用 URL 创建文件消息
OpenIM React Native SDK 使用 URL 创建文件消息。
使用 createFileMessageByURL() 根据已上传文件的资源信息创建消息。
const message = await OpenIMSDK.createFileMessageByURL({
filePath: '',
fileName: '产品说明.pdf',
uuid: 'file-001',
sourceUrl: 'https://www.example.com/产品说明.pdf',
fileSize: 256000,
fileType: 'application/pdf',
});参数说明
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
filePath | string | 是 | 本地文件路径;只有远端资源时传空字符串。 |
fileName | string | 是 | 对外展示的文件名。 |
uuid | string | 是 | 文件资源标识。 |
sourceUrl | string | 是 | 已上传文件的地址。 |
fileSize | number | 是 | 文件大小,单位为字节。 |
fileType | string | 否 | 文件类型。 |
调用后返回待发送的 MessageItem。资源信息应以实际上传结果为准,发送时使用发送已上传的媒体消息。
这个页面有帮助吗?