Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app x

Create an image message from a local file

Create a pending image message from an accessible local image file path.

Copy

Invoke createImageMessageFromFullPath() to construct a pending image message from a local filesystem path accessible to the native application engine. This method does not accept browser File objects or require pre-populating thumbnail dimensions.

Parameters

ParameterTypeRequiredDescription
imageFullPathstringYesAbsolute POSIX file path or unifile:// URI accessible to the native runtime.

Code example

import {
  createImageMessageFromFullPath,
} from '@/uni_modules/unix-openim-sdk'

const message = await createImageMessageFromFullPath(imageFullPath)
if (message == null) return

Ensure imageFullPath points to a permanent local path, such as one resolved within uni.env.USER_DATA_PATH. Temporary gallery picker paths or sandbox-restricted locations may become inaccessible; copy picker results to your application's data directory before calling this method.

Return value

The Promise resolves with an OpenIMMessageItem | null object containing the local image message representation.

State changes after the call

Pass the created message to Send a message. The SDK will automatically handle binary upload and remote dispatch, allowing you to monitor upload progress via onSendMessageProgress and index items by clientMsgID.