createImageMessageFromFullPath
Description
info
Create an image message. The SDK extracts image information based on the absolute path and creates the image message internally.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<Message> createImageMessageFromFullPath({
required String imagePath,
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| imagePath | String | Yes | Absolute path |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message msg = await OpenIM.iMManager.messageManager.createImageMessageFromFullPath(imagePath: imagePath);
//todo
Function Prototype
+ (OIMMessageInfo *)createImageMessageFromFullPath:(NSString *)imagePath;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| imagePath | NSString | Yes | Absolute path |
Return Result
| Name | Type | Description |
|---|---|---|
| message | OIMMessageInfo | Success return |
Code Example
OIMMessageInfo *message = [OIMMessageInfo createImageMessageFromFullPath:@""];
Function Prototype
public Message createImageMessageFromFullPath(String imagePath)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| imagePath | String | Yes | Absolute path |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message Message= OpenIMClient.getInstance().messageManager. createImageMessageFromFullPath( imagePath);
//todo
Note
Only supported when called using ffi in electron.
On the Web side, it is recommended to use createImageMessageByURL or createImageMessageByFile.
Function Prototype
IMSDK.createImageMessageFromFullPath(imagePath: string, operationID?: string): Promise<WsResponse<MessageItem>>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| imagePath | string | Yes | File path, absolute path |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse<MessageItem>> | Success callback |
| Promise.catch() | Promise<WsResponse> | Failure callback |
Code Example
import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
const { instance: IMSDK } = getWithRenderProcess();
IMSDK.createImageMessageFromFullPath('file://...')
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('createImageMessageFromFullPath', operationID: string, imagePath: string): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| imagePath | string | Yes | Absolute image path |
Return Result
Use the
openim-uniapp-polyfillpackage to make the function Promise. When calling, you need to usethenandcatchto determine and handle success and failure callbacks.
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<MessageItem> | Success callback |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('createImageMessageFromFullPath', IMSDK.uuid(), 'imagePath')
.then((data) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.createImageMessageFromFullPath(imagePath: string, operationID?: string): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| imagePath | string | Yes | Absolute image path |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<MessageItem> | Success callback |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
OpenIMSDK.createImageMessageFromFullPath('imagePath')
.then((data) => {
// Call successful
})
.catch((error) => {
// Call failed
});
Function Prototype
public static Message CreateImageMessageFromFullPath(string imageFullPath)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| imageFullPath | string | Yes | Absolute path |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
var msg = IMSDK.CreateImageMessageFromFullPath(imageFullPath);