Browse SDKs · React Native
SDKsReact Native

Create an image message from a URL

OpenIM React Native SDK guide for create an image message from a url.

Copy

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

ParameterTypeRequiredDescription
sourcePicturePicBaseInfoYesSource-image resource information.
bigPicturePicBaseInfoYesLarge-image resource information.
snapshotPicturePicBaseInfoYesThumbnail resource information.
sourcePathstringYesLocal 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.