SDKsiOS
Create a file message from a URL
Create a file message from a previously uploaded URL with OpenIM iOS SDK.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
fileURL | NSString * | Yes | Accessible remote download URL of the uploaded file. |
fileName | NSString * | Yes | File display name shown on the recipient interface. |
size | NSInteger | Yes | Actual 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
- Local memory instantiation: This method constructs an in-memory message object without writing to the database or initiating network activity.
- 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.
Was this page helpful?