Is there a way to get file size with SharePoint 2010 REST (via _vti_bin/ListData.svc
) service?
The same question about number of items in some folder.
I don't see such fields in items corresponding to documents.
2 Answers
It does not seem possible to retrieve File Size using SharePoint 2010 REST Interface.
But you could consider to retrieve file size from Content-Length
header via HTTP HEAD request (without downloading a file).
JavaScript example:
function getFileSize(fileUrl,success) {
$.ajax({
type: "HEAD",
url: fileUrl,
success : function(message,text,response){
var fileSize = response.getResponseHeader('Content-Length');
success(fileSize);
}
});
}
-
1Yes, I tried HEAD request but server responds with HTTP 501. I consider SOAP instead.– andriiMar 26, 2015 at 14:35
You can get file size with REST services in SharePoint 2010.
This link has details of using REST Service to get file size
You need to use code mentioned in above link.
-
Please add substantial part of the post in your answer to save it for future use. Mar 23, 2015 at 5:24
-
2Please don’t add just a link as answer to a question. If the link breaks, the answer you provided will not be useful for future visitors. Provide an answer of your own and use the link as reference. If needed, you can block quote the content from your link. More information is found in our help center, especially How do I write a good answer– Benny Skogberg ♦Mar 23, 2015 at 7:01
-
2Please read my question carefully! I need SP 2010 (_vti_bin/ListData.svc) and GET file size– andriiMar 24, 2015 at 6:33