如何在没有共享选项(Office 365)的情况下在文档库中上载文档或检索文档(外部用户). [英] how to upload document or retrieve document(External User) in Document Library without Sharing option(Office 365).

查看:71
本文介绍了如何在没有共享选项(Office 365)的情况下在文档库中上载文档或检索文档(外部用户).的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

外部用户将上传文档或从文档库中检索文档

External User will upload document or retrieve document from Document Library

没有共享选项(Sharepoint在线站点).

without Sharing option(Sharepoint Online Site).

您能提出建议吗?

推荐答案

没有共享选项,我们需要使用SharePoint Online CSOM库在文档库中下载和上传文档.

Without sharing option, we need to use SharePoint Online CSOM library to download and upload documents within Document Library.

以下是一些代码演示供您参考:

Here are some code demos for your reference:

上传文件:

using (var clientContext = new ClientContext(url))
{
     using (var fs = new FileStream(fileName, FileMode.Open))
     {
         var fi = new FileInfo(fileName);
         var list = clientContext.Web.Lists.GetByTitle(listTitle);
         clientContext.Load(list.RootFolder);
         clientContext.ExecuteQuery();
         var fileUrl = String.Format("{0}/{1}", list.RootFolder.ServerRelativeUrl, fi.Name);

         Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, fileUrl, fs, true);
     }
}

下载文件:

using (var clientContext = new ClientContext(url))
{

     var list = clientContext.Web.Lists.GetByTitle(listTitle);
     var listItem = list.GetItemById(listItemId);
     clientContext.Load(list);
     clientContext.Load(listItem, i => i.File);
     clientContext.ExecuteQuery();

     var fileRef = listItem.File.ServerRelativeUrl;
     var fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, fileRef);
     var fileName = Path.Combine(filePath,(string)listItem.File.Name);
     using (var fileStream = System.IO.File.Create(fileName))
     {                  
          fileInfo.Stream.CopyTo(fileStream);
     }
}

更多信息:

SHAREPOINT 2016/2013/在线:如何通过POWERSHELL自动化来下载SHAREPOINT文件

上传大文件PowerShell csom连接到SharePoint在线文档库

谢谢

最好的问候


这篇关于如何在没有共享选项(Office 365)的情况下在文档库中上载文档或检索文档(外部用户).的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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