从自定义团队应用程序选项卡将文件上传到团队 onedrive
Uploading a file to the teams onedrive from custom teams app tab
我试图在我的自定义团队应用程序中获取选项卡以从 URL 中获取文件列表,然后想将其中一个文件上传到相应的团队 onedrive。我已经能够完成第一部分(获取文件列表),但我完全不知道如何使用 Graph API 或传入的 webhook,或任何可用于将文件上传到团队 onedrive 的解决方案,而无需手动上传它。我如何让我的应用程序将文件从 URL 上传到团队?
我现在的代码:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import React from 'react';
import './App.css';
import * as microsoftTeams from "@microsoft/teams-js";
class Tab extends React.Component {
constructor(props){
super(props)
this.state = {
context: {}
}
}
componentDidMount(){
microsoftTeams.getContext((context, error) => {
this.setState({
context: context
});
});
}
componentDidMount() {
fetch("https://posts123.free.beeceptor.com")
.then(res => res.json())
.then(
(result) => {
this.setState({
isLoaded: true,
files: result.files
});
},
(error) => {
this.setState({
isLoaded: true,
error
});
}
)
}
render() {
const { error, isLoaded, files } = this.state;
if (error) {
return <div>Error: {error.message}</div>;
} else if (!isLoaded) {
return <div>Loading...</div>;
} else {
return (
<ul>
{files.map(file => (
<li key={file.id}>
{file.name} {file.type}
</li>
))}
</ul>
);
}
}
}
export default Tab;
我需要从该列表中选择一个项目,然后使用图表 API 或其他解决方案将该文件上传到团队 onedrive,我该怎么做?
非常感谢任何帮助!附带一提,我是 javascript.
的新手
您可以从 URL 上传文件,Drive using Graph API。你可以通过这个 documentation 提供 API 上传文件。
我试图在我的自定义团队应用程序中获取选项卡以从 URL 中获取文件列表,然后想将其中一个文件上传到相应的团队 onedrive。我已经能够完成第一部分(获取文件列表),但我完全不知道如何使用 Graph API 或传入的 webhook,或任何可用于将文件上传到团队 onedrive 的解决方案,而无需手动上传它。我如何让我的应用程序将文件从 URL 上传到团队?
我现在的代码:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import React from 'react';
import './App.css';
import * as microsoftTeams from "@microsoft/teams-js";
class Tab extends React.Component {
constructor(props){
super(props)
this.state = {
context: {}
}
}
componentDidMount(){
microsoftTeams.getContext((context, error) => {
this.setState({
context: context
});
});
}
componentDidMount() {
fetch("https://posts123.free.beeceptor.com")
.then(res => res.json())
.then(
(result) => {
this.setState({
isLoaded: true,
files: result.files
});
},
(error) => {
this.setState({
isLoaded: true,
error
});
}
)
}
render() {
const { error, isLoaded, files } = this.state;
if (error) {
return <div>Error: {error.message}</div>;
} else if (!isLoaded) {
return <div>Loading...</div>;
} else {
return (
<ul>
{files.map(file => (
<li key={file.id}>
{file.name} {file.type}
</li>
))}
</ul>
);
}
}
}
export default Tab;
我需要从该列表中选择一个项目,然后使用图表 API 或其他解决方案将该文件上传到团队 onedrive,我该怎么做?
非常感谢任何帮助!附带一提,我是 javascript.
的新手您可以从 URL 上传文件,Drive using Graph API。你可以通过这个 documentation 提供 API 上传文件。