今天想要提升一下目前上傳元件的功能,需要支援拖拉資料夾的上傳。
昨天已經成功上傳所有目錄檔案,只差建資料夾的整合。
需要一個api來自動建立不存在的資料夾!!,之前已經有實作直接建資料夾的webscript。
目前需要一個如何判斷一個資料夾是否存在的方法。
以下是簡單的範例
function main() { var parentUUID = json.get("parentUUID"); var folderPath = json.get("folderPath"); //get node owner var nodeOwner = person.properties.userName; //get current nodeRef var currentNodeRef = search.findNode("workspace://SpacesStore/" + parentUUID); if(currentNodeRef == null){ status.setCode(404, "UUID not found"); } //check target folder exist or not var targetFolderNode = currentNodeRef.childByNamePath(folderPath); if(targetFolderNode != null){ if(targetFolderNode.isContainer){ //folder exist model.targetNode = targetFolderNode; }else{ //foler isn't eixst //Existing file or folder test already exists //targetFolderNode = createFolder(currentNodeRef,nodeOwner,folderPath); //model.targetNode = targetFolderNode; status.setCode(500, "Existing file or folder test already exists"); } }else{ //foler isn't eixst targetFolderNode = createFolder(currentNodeRef,nodeOwner,folderPath); model.targetNode = targetFolderNode; }
沒有留言:
張貼留言
留個話吧:)