Alfresco webscript to get the list of all files and folder with their size

梦想与她 提交于 2019-12-02 22:45:06

问题


Need a js based alfresco webscript to get the list of all folders and files recursively alond with their size.


回答1:


CMIS Query:

select cmis:objectId, cmis:name, cmis:contentStreamLength 
from cmis:document 
where cmis:contentStreamLength>0 
order by cmis:contentStreamLength desc
  • HTTP GET:

    http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/
      ?cmisselector=query
      &succinct=true
      &q=select cmis:objectId, cmis:name, cmis:contentStreamLength from cmis:document where cmis:contentStreamLength>0 order by cmis:contentStreamLength desc
    
  • JavaScript:

    Use search root object:

    search - org.alfresco.repo.jscript.Search - Root object providing access to the various Alfresco search interfaces such as FTS-Alfresco, Lucene, XPath, and Saved Search results

    var rs=search.query({
        query:"select * from cmis:document where cmis:contentStreamLength>0 order by cmis:contentStreamLength desc",
        language:"cmis-alfresco"         
    });
    
    for (var r in rs){
        logger.log(rs[r].parent.nodeRef.id+"/"+rs[r].nodeRef.id+"\t"+rs[r].parent.name+"/"+rs[r].name+"\t"+rs[r].size);
    }
    



回答2:


Yes it is possible. you can get the all folders,subfolders,and all the files using repository javascript Please try this code give proper path values

var path="Data Dictionary/***";
var documentLibrary = companyhome.childByNamePath("path");

var children = documentLibrary.children;

traverse(children);

function traverse(nodes){
  for each(var node in nodes) {
    if (node.isContainer){
      logger.log(node.name + " is a folder, traversing down");
      traverse(node.children);
    }else {
      logger.log(node.name ); 
        logger.log(node.size); 
    }
  }
}


来源:https://stackoverflow.com/questions/40792695/alfresco-webscript-to-get-the-list-of-all-files-and-folder-with-their-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!