从SharePoint外部的另一个应用程序上载在线SharePoint网站集文档库中的文档 [英] Upload document in online SharePoint site collection document library from another application outside SharePoint

查看:121
本文介绍了从SharePoint外部的另一个应用程序上载在线SharePoint网站集文档库中的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我已经开发了在Online SharePoint 2016网站集上运行的SharePoint应用.

  1. I have developed a SharePoint App that is running on Online SharePoint 2016 site Collection.

具有另一个在我的其他在线服务器上运行的带有Rest API的软件应用程序.更多此应用程序是完全使用HTML,Javascript/JQuery开发的.没有服务器端脚本.

Have another Software Application with Rest API that is running on my another Online server. More this app is purely developed using HTML,Javascript/JQuery. no server side scripting.

更多SharePoint应用程序已与我的软件应用程序牢固集成(使用Ajax调用进行数据提取).

More SharePoint App strongly integrated with my Software Application (using Ajax calls for data fetching).

现在的问题是,我想从软件应用程序将文件上传到SharePoint.

Now the issue is, i want to upload files into SharePoint from Software Application.

注意:根据我的研发,Office 365联机帐户中不提供匿名访问.

Note: Anonymous access is not available in Office 365 Online account as per my R&D.

请帮助并提前致谢.

推荐答案

您可以按照以下步骤使用REST API和jQuery上传文件:

You can follow the steps below to upload a file by using the REST API and jQuery:

  1. 使用需要HTML5支持的FileReader API将本地文件转换为数组缓冲区. jQuery(document).ready函数在浏览器中检查FileReader API支持.
  2. 通过使用文件夹文件集合上的Add方法将文件添加到Shared Documents文件夹中. 数组缓冲区在POST请求的正文中传递.
  3. 通过使用上载文件的ListItemAllFields属性获取与上载文件相对应的列表项.
  4. 使用MERGE请求更改列表项的显示名称和标题.
  1. Convert the local file to an array buffer by using the FileReader API, which requires HTML5 support. The jQuery(document).ready function check FileReader API support in the browser.
  2. Add the file to the Shared Documents folder by using the Add method on the folder's file collection. The array buffer is passed in the body of the POST request.
  3. Get the list item that correspond to uploaded file by using the ListItemAllFields property of uploaded file.
  4. Change the display name and title of the list item by using a MERGE request.

这些示例使用getfolderbyserverrelativeurl端点到达文件集合. 您还可以使用列表端点(例如:…/_api/web/lists/getbytitle('')/rootfolder/files/add).

These examples use the getfolderbyserverrelativeurl endpoint to reach the file collection. You can also use a list endpoint (example: …/_api/web/lists/getbytitle('')/rootfolder/files/add).

有关更多信息,请查看以下链接:

For more information, please review the following link: Upload a file by using the REST API and jQuery

这篇关于从SharePoint外部的另一个应用程序上载在线SharePoint网站集文档库中的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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