createFileMessageFromFullPath
Description
info
Create a file message. The SDK extracts file information based on the absolute path and creates the file message internally.
- iOS
- Android
- Flutter
- uni-app
- Browser/MiniProgram
- React-Native
- Unity
Function Prototype
Future<Message> createFileMessageFromFullPath({
required String filePath,
required String fileName,
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| filePath | String | Yes | Absolute path |
| fileName | String | Yes | File name |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message msg = await OpenIM.iMManager.messageManager.createFileMessageFromFullPath(filePath: filePath, fileName: fileName);
//todo
Function Prototype
+ (OIMMessageInfo *)createFileMessageFromFullPath:(NSString *)filePath
fileName:(NSString *)fileName;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| filePath | NSString | Yes | Absolute path |
| fileName | NSString | Yes | File name |
Return Result
| Name | Type | Description |
|---|---|---|
| message | OIMMessageInfo | Success return |
Code Example
OIMMessageInfo *message = [OIMMessageInfo createFileMessageFromFullPath:@"" fileName:@""];
Function Prototype
public Message createFileMessageFromFullPath(String filePath, String fileName)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| filePath | String | Yes | Absolute path |
| fileName | String | Yes | File name |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message Message= OpenIMClient.getInstance().messageManager. createFileMessageFromFullPath( filePath, fileName)
Note
Only supported when called using ffi in electron.
On the Web side, it is recommended to use createFileMessageByURL or createFileMessageByFile
Function Prototype
IMSDK.createFileMessageFromFullPath({
filePath: string;
fileName: string;
}, operationID?: string): Promise<WsResponse<MessageItem>>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| filePath | string | Yes | File path, absolute path |
| fileName | string | Yes | File name |
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.createFileMessageFromFullPath({
filePath: 'file://...',
fileName: 'fileName.mp4',
})
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('createFileMessageFromFullPath', operationID: string, {
filePath: string,
fileName: 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 |
| filePath | number | Yes | Absolute file path |
| fileName | string | Yes | File name |
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('createFileMessageFromFullPath', IMSDK.uuid(), {
filePath: '',
fileName: '',
})
.then((data) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.createFileMessageFromFullPath({
filePath: string,
fileName: string
}, operationID?: string): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| filePath | number | Yes | Absolute file path |
| fileName | string | Yes | File name |
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
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.createFileMessageFromFullPath({
filePath: '',
fileName: '',
})
.then(({ data }) => {
// Call successful
})
.catch((error) => {
// Call failed
});
Function Prototype
public static Message CreateFileMessageFromFullPath(string fileFullPath, string fileName)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| filePath | string | Yes | Absolute path |
| fileName | string | Yes | File name |
Return Result
| Name | Type | Description |
|---|---|---|
| message | Message | Success return |
Code Example
var msg = IMSDK.CreateFileMessageFromFullPath(fileFullPath,fileName);