尝试将文档上载到文档库时出现列表视图阈值问题。让我给你讲故事的背景。
我的CSOM代码可以创建文件夹,但是无法将文档上传到该文件夹,因为SharePoint表示我们已经达到列表视图阈值。
我们要上载文档的文档库中有超过2万个项目。
一段时间以来,我们一直在使用相同的代码,但是截至2019年10月,一切都停止了工作。
有什么想法吗?下面提供的是我正在使用的代码 使用(ClientContext ctx = new ClientContext(SPUrl)) { ctx.Credentials =新的SharePointOnlineCredentials(spuser,securePassword);
import React, { useEffect, useState } from "react";
import app from "./config/base.js";
import axios from "axios";
export default class RepRequest extends React.Component {
constructor(props) {
super(props);
this.state = {
userInfo: [],
fedSens: [],
fedReps: []
};
}
componentDidMount() {
const items = [];
app.auth().onAuthStateChanged(function(user) {
if (user) {
console.log("User is signed in");
let db = app
.firestore()
.collection("user")
.doc(user.uid);
db.get().then(doc => {
if (doc.exists) {
console.log("Document data:", doc.data());
items.push(doc.data());
} else {
console.log("No doc exists");
}
});
}
this.setState({ userInfo: items });
});
Promise.all([
axios.get(
`https://api.propublica.org/congress/v1/116/senate/members.json`,
{
headers: { "X-API-Key": "9wGKmWl3kNiiSqesJf74uGl0PtStbcP2mEzSvjxv" }
}
),
axios.get(
`https://api.propublica.org/congress/v1/116/house/members.json`,
{
headers: { "X-API-Key": "9wGKmWl3kNiiSqesJf74uGl0PtStbcP2mEzSvjxv" }
}
)
]).then(([rest1, rest2]) => {
this.setState({
fedSens: rest1,
fedReps: rest2
});
});
}
render() {
if (this.state.fedReps.length <= 0)
return (
<div>
<span>Loading...</span>
</div>
);
else {
console.log(this.state.fedReps);
return <div>test</div>;
}
}
}
答案 0 :(得分:0)
我的示例测试代码(该库有超过1万个文件)。
for
或者(该文件夹包含超过1万个文件)
List docs = context.Web.Lists.GetByTitle("largeLib1");
var filePath = @"C:\Lee\template.xlsx";
using (FileStream fs = new FileStream(filePath, FileMode.Open))
{
FileCreationInformation flciNewFile = new FileCreationInformation();
flciNewFile.ContentStream = fs;
flciNewFile.Url = System.IO.Path.GetFileName(filePath);
flciNewFile.Overwrite = true;
Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(flciNewFile);
context.Load(uploadFile);
context.ExecuteQuery();
}
答案 1 :(得分:0)
我发现了问题所在。问题是调用ctx.Load(docs.RootFolder.Folders);我删除了这段代码,现在可以上传文档了。