SharePoint REST API 在下载过程中返回不完整的文件内容 [英] SharePoint REST API returns incomplete content of file during downloading

查看:60
本文介绍了SharePoint REST API 在下载过程中返回不完整的文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发用于获取和下载 SharePoint 数据的应用程序.对于 SharePoint 中的每个文件夹,我可以使用下一个 SharePoint REST API 端点获取给定文件夹中所有文件的列表:

I work on application for fetching and downloading SharePoint data. For every folder in SharePoint I can get the list of all files inside given folder by using next SharePoint REST API endpoint:

/_api/web/GetFolderById('')/Files

为每个文件提供了预期的大小和 guid,因此我可以在下载文件时使用它们.然后我使用 SharePoint REST API 中的下一个端点来实际获取文件内容:

The expected size and guid is provided for every file so I can use them when I want to download the file. Then I use the next endpoint from SharePoint REST API in order to actually get file content:

/_api/web/GetFileById('')/$value

有时,当我下载文件时,我得到的数据比预期的要少:下载数据的大小与我在获取文件属性列表时获得的值不同.但是,当我再次尝试获取其内容时,它可以成功下载(下载数据的大小等于预期值),或者我可以获得另一个不完整的数据.

From time to time when I download the file I get less data than expected: size of downloaded data is just different from the value I obtain while getting the properties list of files. However when I try to get its content again it can be successfully downloaded (size of downloaded data is equal the expected value) or I can get another incomplete data.

我确认第一个端点(用于获取文件夹中所有文件的属性)返回正确的文件大小.问题在于第二个的调用.

I verified that the first endpoint (one used to get properties of all files in the folder) returns the correct file size. The problem is in the call of the second one.

我看到 "transfer-encoding" 标头中的chunked"值回复.因此,当我的 http 客户端执行分块数据下载时,如果在某个时刻收到零块,那么我们就到达了正文的末尾 根据定义.因此,在某些情况下,SharePoint 似乎返回不完整的数据或不应该发送的零块.

I see that there is "transfer-encoding" header with "chunked" value in response. So when my http client performs chunked data download and if zero chunk is received at some point then we reached the end of the body by definition. So it looks like in some cases SharePoint either returns the incomplete data or zero chunks when they should not be sent.

这种奇怪行为的原因是什么?这是一个知识问题吗?

What can be the reason of such strange behavior? Is it a know issue?

推荐答案

我们实际上也看到了这种奇怪的行为,许多文件只是很小的 aspx 文件,大约 3-4kb 并且它们不断地小 15% 并且比看起来的要多在文件属性中.我们也在使用 REST API,这真的很令人沮丧.Sharepoint Online 中所有这些奇怪的错误都非常烦人.

We actually also see this, strange behaviour, many files are just small aspx files, about 3-4kb and they are constantly smaller by 15% and more than appears in file propertis. We're also using REST API and this is really frustrating. All those strange bugs in Sharepoint Online are very annoying.

这篇关于SharePoint REST API 在下载过程中返回不完整的文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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