Browse SDKs · iOS
Platform
SDKsiOS

Create a file message from a local path

Create a file message from an absolute path with OpenIM iOS SDK.

Copy

Invoke createFileMessageFromFullPath:fileName: on OIMMessageInfo to construct a file message from an absolute file path in the local application sandbox. The SDK automatically uploads the file to object storage during message dispatch:

Parameters

ParameterTypeRequiredDescription
filePathNSString *YesAbsolute path to the file within the application sandbox.
fileNameNSString *YesFile display name shown in conversation message bubbles.

Code example

OIMMessageInfo *message =
    [OIMMessageInfo createFileMessageFromFullPath:fileURL.path
                                         fileName:fileURL.lastPathComponent];

Return value

Returns an initialized OIMMessageInfo model with its content type set to file.

State changes after the call

  1. Local memory instantiation: This method builds an in-memory message model without persisting records to local storage or initiating network uploads immediately.
  2. Subsequent dispatch: Call Send a message to execute file upload and deliver the message. If the file is already uploaded to remote storage, use Create a file message from a URL.