SharePoint文档库的REST URL [英] REST urls for SharePoint Document Library

查看:82
本文介绍了SharePoint文档库的REST URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我可以毫无问题地将文件上传到文档库。

So, I am able to upload a file to a document library without a problem.

如果我想在上传文件时更新自定义列,该怎么办。  ;例如,有一个名为"月"的列。以及一个名为"年"的列。 如何上传文件并更新"月份"?和"年"同时为该文件列

What if I want to update a custom column as I upload the file.  For example, there is a column called "Month" and a column called "Year".  How can I upload the file and update the "Month" and "Year" columns for that file at the same time?

推荐答案

您无法在上传的同一个调用中更新元数据值该文件,您必须在单独的电话中这样做。上传文档的调用的响应将是一个SP.File对象,表示刚刚创建的文件。这个对象将
有一个名为ListItemAllFields的deffered属性,您可以使用它来获取调用所需的URL以获取与该文件关联的列表项。

You can't update metadata values in the same call that uploads the document, you have to do that in a separate call. The response from the call that uploads the document will be a SP.File object representing the file that was just created. This object will have a deffered property called ListItemAllFields, which you can use to get the URL needed to make a call to get the list item associated with the file.

 

https://sharepoint.stackexchange.com/questions/76583/rest-post-with-metadata-column


function
uploadDocument(buffer,fileName){


 &n BSP; 
var
url =
字符串 .format( " {0} / _ api / Web / Lists / getByTitle('Project
Documents')/ RootFolder / Files / Add(url ='{1}',overwrite = true )"


       
_spPageContextInfo.webAbsoluteUrl,fileName);

        _spPageContextInfo.webAbsoluteUrl, fileName);



   
var
call = jQuery.ajax({


       
url:url,

        url: url,


      ;  
类型:
" POST"


       
数据:缓冲区,

        data: buffer,


       
processData:

        processData: false,


       
标题:{

        headers: {


           
接受
" application / json; odata = verbose"


           
" X-RequestDigest"
jQuery(
" #__ REQUESTDIGEST" )。val(),


           
" Content-Length"
buffer.byteLength


       
}

        }


   
});

    });



   
返回
电话;


}



功能
getItem(文件){


这篇关于SharePoint文档库的REST URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆