TIMMsgDownloadElemToPath

功能介绍

下载消息内元素到指定文件路径(图片、视频、音频、文件)

此接口用于下载消息内图片、文件、声音、视频等元素。下载的参数 msg_download_elem_param_flag、msg_download_elem_param_id、msg_download_elem_param_business_id、msg_download_elem_param_url 均可以在相应元素内找到。其中 msg_download_elem_param_type 为下载文件类型 TIMDownloadType,参数 path 要求是 UTF-8 编码

参数详解

参数名称 参数类型 是否必填 描述
msgDownloadElemToPathParams MsgDownloadElemToPathParams 下载消息的参数

返回模板

Promise<commonResult<DownloadElemResult>>

{
    code: TIMResult | TIMErrCode;
    desc?: string | undefined;
    json_param?: DownloadElemResult | undefined;
    json_params?: DownloadElemResult | undefined; // 兼容
    user_data?: string | undefined;
}

返回值详解

名称 数值类型 描述
code TIMResultTIMErrCode 返回状态码
desc string | undefined 返回描述
json_param DownloadElemResult | undefined 根据具具体接口返回
json_params DownloadElemResult | undefined 兼容的字段,某些情况下会返回这个,根据具体接口返回
user_data string | undefined ImSDK负责透传的用户自定义数据,未做任何处理

代码示例

import TimRender from "im_electron_sdk/dist/renderer";
const timRenderInstance = new TimRender();
import { MsgDownloadElemToPathParams,Json_download_elem_param } from "im_electron_sdk/dist/interfaces";
let params : Json_download_elem_param = {
    msg_download_elem_param_flag: 0,
    msg_download_elem_param_type: 0,
    msg_download_elem_param_id: '',
    msg_download_elem_param_business_id: 0,
    msg_download_elem_param_url: ''
}
let param:MsgDownloadElemToPathParams = {
    params: params,
    path: '',
    user_data: ''
}

const {code} = await timRenderInstance.TIMMsgDownloadElemToPath(param);
if(code == 0){
    // 成功
}

results matching ""

    No results matching ""