【问题标题】: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
【问题描述】:

我可以在 spfx webpart 中使用 SPHttpClient 将文件上传到文档库。但是我不知道如何添加与文档关联的相应列数据。

例如 候选人的详细信息和简历。简历将是文档,姓名、电子邮件等详细信息将是该文档库特定行中的相应详细信息

我已参考以下链接上传文件。如果有人也可以添加代码来更新列,那将会很有帮助 Upload files to SharePoint Online using SPHttpClient in an spfx webpart

【问题讨论】:

    标签: 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

    【讨论】:

      猜你喜欢
      • 2019-02-06
      • 2016-04-29
      • 2022-06-30
      • 2018-12-28
      • 1970-01-01
      • 2021-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多