Create an image message from URLs
Create an image message from uploaded image data with the OpenIM Flutter SDK.
Construct an image message object using image URLs and metadata already uploaded to external object storage (such as S3, OSS, or COS):
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sourcePicture | PictureInfo | Yes | Original image details, including URL, file byte size, width, and height. |
bigPicture | PictureInfo | Yes | Large image details, including URL, file byte size, width, and height. |
snapshotPicture | PictureInfo | Yes | Thumbnail image details, including URL, file byte size, width, and height. |
Code example
final message = await OpenIM.iMManager.messageManager.createImageMessageByURL(
sourcePicture: source,
bigPicture: big,
snapshotPicture: snapshot,
);The URL, byte size, width, and height in each PictureInfo instance must originate from authentic media upload results so recipients can render and preview the image accurately.
Return value
Returns a Future resolving to an image Message object ready for transmission. Its image attributes are stored in pictureElem.
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 image has already been uploaded, pass the returned Message instance to Send a message without OSS to deliver it without re-uploading. If you need the SDK to upload local images automatically, see Create an image message.
Was this page helpful?