Create a file message from a URL
Create a file message from an uploaded file element with the OpenIM Flutter SDK.
Construct a file message object using file metadata and a download URL already uploaded to external object storage:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fileElem | FileElem | Yes | File metadata model containing the verified download URL, UUID, display file name, and byte size. |
Code example
final message = await OpenIM.iMManager.messageManager
.createFileMessageByURL(fileElem: fileElem);The URL, file name, and size in FileElem must reflect actual media upload results to enable recipients to display file sizes correctly and download files reliably.
Return value
Returns a Future resolving to a file Message object ready for transmission. Its file payload is stored in fileElem.
State changes after the call
Creating a message only constructs the local message data structure in memory; it does not perform network transmission and does not trigger new-message event callbacks. Because the file has already been uploaded, pass the returned Message instance to Send a message without OSS to deliver it without duplicate uploads. If you need the SDK to upload local files automatically, see Create a file message.
Was this page helpful?