【问题标题】:Upload files to SharePoint Online using SPHttpClient in an spfx webpart with the corresponding column data在 spfx webpart 中使用 SPHttpClient 将文件上传到 SharePoint Online,并带有相应的列数据
【发布时间】:2020-05-12 12:36:38
【问题描述】:
【问题讨论】:
标签:
httpclient
sharepoint-online
spfx
【解决方案1】:
您需要先上传文件,然后更新文件项元数据(列值)。
PnP/PnPjs 是 SPFx 中最流行的库,也有助于满足您的要求。
sp.web.getFolderByServerRelativeUrl("your site/PnpLibrary").files.add(myfile.name, myfile, true).then(f => {
console.log("File Uploaded");
f.file.getItem().then(item => {
item.update({
Title: "Metadata Updated"
}).then((myupdate) => {
console.log(myupdate);
console.log("Metadata Updated");
});
});
});
demo thread here