Browse SDKs · iOS
Platform
SDKsiOS

Create an image message from a URL

Create an image message from a previously uploaded URL with OpenIM iOS SDK.

Copy

When the application has already uploaded image assets to object storage and possesses remote URLs, invoke createImageMessageByURL:sourcePicture:bigPicture:snapshotPicture: on OIMMessageInfo to construct an image message object directly without redundant uploads by the SDK:

Parameters

ParameterTypeRequiredDescription
sourcePathNSString *YesLocal source path. Pass an empty string @"" when referencing remote resources directly.
sourcePictureOIMPictureInfo *YesOriginal image metadata object containing remote URL, dimensions, and file size.
bigPictureOIMPictureInfo *YesHigh-resolution image metadata object.
snapshotPictureOIMPictureInfo *YesThumbnail image metadata object.

Code example

OIMMessageInfo *message =
    [OIMMessageInfo createImageMessageByURL:@""
                              sourcePicture:source
                                 bigPicture:big
                            snapshotPicture:snapshot];

Return value

Returns an initialized OIMMessageInfo model populated with the remote image information. The URLs, dimensions, and file sizes across all three OIMPictureInfo objects must represent valid remote assets.

State changes after the call

  1. Local memory instantiation: This method constructs an in-memory message object without writing to the local database or initiating network requests.
  2. Subsequent dispatch: Because media assets are already uploaded, deliver the message by calling Send a message without SDK-managed upload. If you want the SDK to handle local file upload automatically, use Create an image message from a local path.