问题描述
你好
我想获取MB和GB的存储详细信息以及所有站点和子站点的百分比.
I want to get the storage details with MB and GB and percentage for all sites and sub sites.
我仅对站点进行了操作,而对子站点不做操作.子网站也要怎么做.
I have done only for sites not sub sites. How to do sub sites also.
例如:
网站名称 储存MB 存储GB 百分比
Site name Storage MB storage GB percentage
网站1 XXXXX XXXX XXXX
Site 1 XXXXX XXXX XXXX
网站1. XXXX XXXX XXXX
site 1. 1 XXXX XXXX XXXX
网站1.1.1 XXXXX xxxxx xxxxx
site 1.1.1 XXXXX xxxxx xxxxx
网站2 XXXXX xxxxx xxxxx
Site 2 XXXXX xxxxx xxxxx
像我想要的那样.
仅查看网站的我的代码:
See the my code only for sites:
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
/*
if (_spPageContextInfo.webServerRelativeUrl === '/') {
var webUrl = '';
}
else{
var webUrl = _spPageContextInfo.webServerRelativeUrl;
}*/
$(function(){
$.ajax({
url: _spPageContextInfo.siteAbsoluteUrl + "/_api/site/usage",
//url: webUrl+ "/_api/site/usage",
type: "GET",
headers: {
"Accept": "application/json;odata=verbose",
},
success: function (data) {
var percent = data.d.Usage.StoragePercentageUsed;
percent = 100*percent;
percent = percent.toFixed(2);
var storage = data.d.Usage.Storage;
storage = storage/1048576;
storage = storage.toFixed(3);
var storageGB = storage/1024;
storageGB =storageGB.toFixed(4);
$("#StoragePercentageUsed").html("<b>StoragePercentageUsed:</b>"+percent+"%");
$("#StorageMB").html("<b>Storage in MB:</b>"+storage+);
$("#StorageGB").html("<b>Storage in GB:</b>"+storageGB+);
},
error: function (data) {
alert("Error");
}
});
});
</script>
<span id="StorageMB"></span>
<br/>
<span id="StorageGB"></span>
<br/>
<span id="StoragePercentageUsed"></span>
<br/>
如何使用REST端点进行子站点使用
how to use REST End point for sub site usage
这是针对站点的:
_spPageContextInfo.siteAbsoluteUrl + "/_api/site/usage
感谢您的帮助.
推荐答案
我们可以使用REST API获取所有子站点的相对URL.
We can get all sub sites relative url using REST API.
/_api/site/rootWeb/webinfos?
然后将"/_api/site/usage"称为REST API.
Then call the "/_api/site/usage" rest api.
更多信息:
https://www. dsouzajoel.com/2016/02/10/get-all-sites-and-sub-sites-using-rest-api/
最好的问候,
这篇关于如何使用Java脚本或RESt获取所有站点和子站点的配额详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!