开发者社区 问答 正文

在钉钉如何获取用户审批评论里的附件?

在钉钉如何获取用户审批评论里的附件?

展开
收起
我很饿很薄啊 2024-06-25 16:45:16 150 分享 版权
2 条回答
写回答
取消 提交回答
  • 使用新版SDK时,除了需要pid和文件的fileId还需要将请求参数withCommentAttatchment设置为true:

        public String getProcessAttachmentV2(String processInstanceId, String fileId) {
            // {field,processInstanceId,withCommentAttatchment}
            com.aliyun.dingtalkworkflow_1_0.Client client = getWorkflowClient();
            GrantProcessInstanceForDownloadFileRequest request = new GrantProcessInstanceForDownloadFileRequest();
            request.setProcessInstanceId(processInstanceId);
            request.setFileId(fileId);
            request.setWithCommentAttatchment(true);
            GrantProcessInstanceForDownloadFileHeaders headers = new GrantProcessInstanceForDownloadFileHeaders();
            headers.xAcsDingtalkAccessToken = getToken();
            try {
                GrantProcessInstanceForDownloadFileResponse response = client.grantProcessInstanceForDownloadFileWithOptions(request, headers, new RuntimeOptions());
                log.debug(response.getBody().toString());
                return response.getBody().getResult().getDownloadUri();
            } catch (Exception e) {
                log.error(e.getMessage());
                return "获取错误";
            }
        }
    

    这样response.getBody().getResult().getDownloadUri()就可以拿到钉钉中附件的下载URL咯!

    2024-12-11 10:40:27
    赞同 1 展开评论
  • 如果您需要获取用户审批评论里的附件,您可以通过以下步骤操作:1. 直接在审批详情页面查看评论部分,附件通常会展示在评论内容下方,可直接点击下载或查看。2. 若需要批量处理或通过API方式获取,可以参考文档https://open.dingtalk.com/document/orgapp/download-an-approval-attachment 了解如何通过接口调用下载审批附件,该文档提供了获取附件下载地址的方法。请注意,评论中已提交的附件和图片不支持删除、修改或撤回。此外,通过审批评论上传的附件会占用企业的云盘空间。-此回答整理自钉群“钉钉开发者社区(互助群)”

    2024-06-26 09:52:02
    赞同 展开评论