我在文档库中获取刚刚上载的文件的Id时遇到问题。有人能帮我检查一下我使用的pnp-js函数是否正确吗?
success: function (file) {
let web: Web = new Web(_context.pageContext.web.absoluteUrl);
console.log("FileUpload success")
web.lists.getById(_listName).rootFolder.files.getByName(file.name).get().then(t => {
//add your code here if you want to do more after deleting the file
console.log(t);
});
}
};
发布于 2019-04-08 20:46:19
您可以通过如下方式获取最近上传的文档ID:
let web: Web = new Web(_context.pageContext.web.absoluteUrl);
// change the path as per your requirement
web.getFolderByServerRelativeUrl("/sites/dev/Shared%20Documents/test/").
files.add(file.name, file, true).then(f => {
console.log("FileUpload success");
f.file.getItem().then(item => {
console.log(item.ID);
});
});
发布于 2019-04-09 00:02:16
我能够找到我刚刚上传的文件的Id,使用下面的代码:
success: function () {
let web: Web = new Web(_context.pageContext.web.absoluteUrl);
web.lists.getById(_listName).items.orderBy('Id', false).top(1).get().then((items: any[]) => {
item = items[0].Id;
});
https://stackoverflow.com/questions/55555402
复制相似问题