繁体   English   中英

从 MS Teams 中的消息扩展上传附件

[英]Upload attachment from messages extension in MS Teams

我在 MS Teams 中运行消息扩展 - 它在 MS Planner 中创建任务。

接下来,我正在寻找添加通过消息扩展上传附件的功能。

下面是消息扩展的 UI - 使用 Adaptive Card (NodeJS) 构建。

那么,如何点击Upload Document打开文件选择器并能够添加附件呢?

在此处输入图片说明

为此,您必须使用具有 Web 视图的消息传递扩展并将其指向您自己的服务器。 据我所知,默认情况下你不能做你所要求的。

https://docs.microsoft.com/en-us/microsoftteams/platform/resources/messaging-extension-v3/create-extensions?tabs=typescript

请参阅此处,“使用 Web 视图进行动态输入”一章

Web 视图显示您自己托管的网站,您可以在那里轻松实现文件上传。

截至目前,自适应卡中没有此类操作可用。 如果您想这样做,您需要创建一个网页并编写用于上传的自定义代码。 您可以使用:

<input type="file" id="attachment" ref={input => this.inputElement = input} style={{ display: "none" }} onChange={e => this.onFileChange(e)} />

请参阅此示例以了解有关基于操作的消息传递扩展 + 自定义网页的更多信息。

谢谢

没有通过自适应卡片Upload Documents功能。

但建议触发web-view ,然后有上传功能。

在此处输入图片说明 消息扩展代码 (NodeJS):关于Upload Documents

...

return {
   task: {
     type: 'continue',
     value: {
       height: 400,
       width: 400,
       title: 'Task module WebView',
       url: `https://mywebsite.example.com`
     }
   }
};

在点击upload documents ,它会是这样的:

在此处输入图片说明

前端代码:

<div>
    <input type="file" class="file-input" (change)="onFileSelected($event)" #fileUpload />

    <div style="margin-left: -175px" class="centered">
        <h2 style="color: #464775; font-weight: bold; margin-bottom: 10px; margin-top: -20px; margin-left: 30px">Add attachemnt to your task</h2>
    
        <div *ngIf="!buttonDisable" style="margin-left: 70px; margin-bottom: 15px">
            {{ uploadSuccess || 'No file uploaded yet.' }}
            <button color="primary" style="margin-left: 10px" class="upload-btn" (click)="fileUpload.click()">
                <i aria-hidden="true" class="fas fa-paperclip"></i>
            </button>
        </div>
    
        <div style="margin-left: 65px" *ngIf="!buttonDisable">
            <button color="primary" class="btn-cm" style="color: #3fb349; margin-left: 35px" (click)="onSubmit()">Submit Task</button>
        </div>
    
        <div *ngIf="buttonDisable" style="margin-left: 39px; margin-top: 30px">
            <label style="color: #3fb349; margin-left: -1px; margin-top: 23px">{{ message }}</label>
            <button color="primary" class="btn-cm" style="color: #3fb349" (click)="closeWindow()">Close</button>
        </div>
    </div>
</div>

丢弃内联css

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM