钉钉自建应用-下载excel(h5)

由于不同手机对于文件下载有不同的支持,而且文件路径也不一样,找起来十分的麻烦。所以,最好是找到一个都支持的方法。还好,钉钉官网提供了网盘,我们可把文件保存到钉钉自带的网盘,这样方便查找。

这里需要后端返回下载文件的url地址

TypeScript 复制代码
dd.saveFileToDingTalk({
  url: 'https://ringnerippca.files.wordpress.com/20.pdf',
  name: '文件名称.pdf',
  success: (res) => {
    const { data } = res;
    dd.previewFileInDingTalk({
      corpId: '应用的corpId',
      fileId: data[0].fileId,
      spaceId: data[0].spaceId,
      fileName: data[0].fileName,
      fileSize: data[0].fileSize,
      fileType: data[0].fileType,
      success: () => {},
      fail: () => {},
      complete: () => {},
    });
  },
  fail: () => {},
  complete: () => {},
});

不过需要注意的是使用这两个api之前需要先鉴权。

TypeScript 复制代码
// 当前网页的URL,不包含#及其后面部分。
ajax(url).then((res) => {
  if (res.data.success) {
      const { agentId, timeStamp, nonceStr, signature } = res.data.content;
      dd.config({
         agentId,
         corpId: '应用的corpId',
         timeStamp,
         nonceStr,
         signature,
         type: 0,
         jsApiList: [
           'saveFileToDingTalk',
           'previewFileInDingTalk'
         ]
      });

      dd.error((err) => {
        console.log('🚀 dd.error ~ err.errorMessage',err.errorMessage);
        console.log('🚀 dd.error ~ err.url', err.url);
      }); // 该方法必须带上,用来捕获鉴权出现的异常信息,否则不方便排查出现的问题
  }
});
相关推荐
2601_958320574 天前
【小白零基础上手 】钉钉内部机器人接入 OpenClaw 完整流程讲解(含安装包)
人工智能·windows·机器人·钉钉·open claw·open claw安装
无心水6 天前
【Hermes:多平台接入】19、钉钉/飞书/企业微信:国内办公场景接入指南 —— 将 Honcho 智能体部署到你的工作聊天软件
人工智能·钉钉·飞书·企业微信·openclaw·hermes·honcho
云中计算巫作坤6 天前
泛微OA,该不该扔?
钉钉·飞书·企业数字化·泛微oa
翼龙云_cloud7 天前
阿里云代理商:阿里云部署的Hermes Agent 钉钉接入指南
人工智能·阿里云·云计算·钉钉·ai 智能体·hermes agent
lizz6668 天前
Hermes-Agent:钉钉dingtalk增加语音识别
人工智能·钉钉·语音识别
tianxiaxue19 天前
企微群内超时提醒通知到飞书/钉钉?
钉钉·飞书·企业微信
lizz66612 天前
Hermes-Agent:钉钉dingtalk配置定时任务收集
人工智能·钉钉
光于前裕于后13 天前
OpenMetadata设置数据质量规则,并通过钉钉告警
钉钉
观测云13 天前
观测云集成钉钉 SSO 最佳实践
钉钉·sso·观测云
终端行者14 天前
Jenkins流水线添加企业微信或者钉钉通知 pipeline 如何通过企微/钉钉通知
ci/cd·jenkins·钉钉·企业微信