createFileMessageFromFullPath
Feature Introduction
Description
Create a file message. The SDK internally extracts file information based on the full path and creates a file message.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<Message> createFileMessageFromFullPath({
required String filePath,
required String fileName,
String? operationID,
})
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
filePath | String | Yes | Absolute path |
fileName | String | Yes | File name |
Return Value
Name | Type | Description |
---|---|---|
~ | Message | Successful 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 | Data Type | Required | Description |
---|---|---|---|
filePath | NSString | Yes | Absolute path |
fileName | NSString | Yes | File name |
Return Value
Name | Type | Description |
---|---|---|
message | OIMMessageInfo | Successful return |
Code Example
OIMMessageInfo *message = [OIMMessageInfo createFileMessageFromFullPath:@"" fileName:@""];
Function Prototype
public Message createFileMessageFromFullPath(String filePath, String fileName)
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
filePath | String | Yes | Absolute path |
fileName | String | Yes | File name |
Return Value
Name | Type | Description |
---|---|---|
~ | Message | Successful return |
Code Example
Message Message= OpenIMClient.getInstance().messageManager. createFileMessageFromFullPath( filePath, fileName)
Note
For the Web platform, it is recommended to use createFileMessageByURL or createFileMessageByFile.
Function Prototype
IMSDK.asyncApi('createFileMessageFromFullPath', operationID: string, {
filePath: string,
fileName: string
}): Promise<MessageItem>
Input Parameters
Parameter Name | Data Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for problem tracking, recommended to use the current time and a random number |
filePath | number | Yes | Absolute file path |
fileName | string | Yes | File name |
Return Value
The function is made Promise-based via the
openim-uniapp-polyfill
package. Usethen
andcatch
to check and handle success and failure callbacks.
Parameter Name | Data 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) => {
// Success callback
})
.catch(({ errCode, errMsg }) => {
// Failure callback
});
Function Prototype
OpenIMSDKRN.createFileMessageFromFullPath({
filePath: string,
fileName: string
}, operationID: string): Promise<MessageItem>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
filePath | number | Yes | File absolute path |
fileName | string | Yes | File name |
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<MessageItem> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.createFileMessageFromFullPath({
filePath: '',
fileName: '',
}, 'operationID')
.then((data) => {
// Success callback
})
.catch(({ errCode, errMsg }) => {
// Failure callback
});
Function Prototype
public static Message CreateFileMessageFromFullPath(string fileFullPath, string fileName)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
filePath | string | Yes | File absolute path |
fileName | string | Yes | File name |
Return Result
Parameter Name | Type | Description |
---|---|---|
message | Message | Message Struct |
Code Example
var msg = IMSDK.CreateFileMessageFromFullPath(fileFullPath,fileName);