SDKsReact Native
Create an image message from a URL
OpenIM React Native SDK guide for create an image message from a url.
Use createImageMessageByURL() to create a message from uploaded image resource information. The source image, large image, and thumbnail can share one resource description or use separate resources with different sizes or quality.
const picture = {
uuid: 'image-001',
type: 'image/jpeg',
size: 120000,
width: 1280,
height: 720,
url: 'https://www.example.com/picture.png',
};
const message = await OpenIMSDK.createImageMessageByURL({
sourcePicture: picture,
bigPicture: picture,
snapshotPicture: picture,
sourcePath: '',
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sourcePicture | PicBaseInfo | Yes | Source-image resource information. |
bigPicture | PicBaseInfo | Yes | Large-image resource information. |
snapshotPicture | PicBaseInfo | Yes | Thumbnail resource information. |
sourcePath | string | Yes | Local image path. Pass an empty string when only a remote resource is available. |
Each PicBaseInfo contains uuid, type, size, width, height, and url: the resource ID, type, byte size, pixel dimensions, and remote URL. The call returns a MessageItem ready to send. Use Send an uploaded media message to send it.
Was this page helpful?