Browse SDKs · iOS
Platform
SDKsiOS

Create a file message from a URL

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

Copy

When the application has already uploaded files or documents to object storage and possesses remote download URLs, invoke createFileMessageByURL:fileName:size: on OIMMessageInfo to construct a file message object directly without redundant uploads by the SDK:

Parameters

ParameterTypeRequiredDescription
fileURLNSString *YesAccessible remote download URL of the uploaded file.
fileNameNSString *YesFile display name shown on the recipient interface.
sizeNSIntegerYesActual size of the file in bytes.

Code example

OIMMessageInfo *message =
    [OIMMessageInfo createFileMessageByURL:uploadedURL
                                  fileName:@"report.pdf"
                                      size:uploadedSize];

Return value

Returns an initialized OIMMessageInfo model populated with the remote file URL and metadata. The passed URL, file name, and file size must match valid asset data.

State changes after the call

  1. Local memory instantiation: This method constructs an in-memory message object without writing to the database or initiating network activity.
  2. Subsequent dispatch: Because the file is already hosted externally, deliver the message by calling Send a message without SDK-managed upload. If you need the SDK to manage local file uploading, use Create a file message from a local path.