marclundgren
7/20/2014 - 9:42 PM

liferay-upload-folders-algorithm.js

function uploadFileTree(treeNode, folderId) {
/*
  return a Promise *(first Promise)*

    if treeNode is a file...

      create an html5 file

      resolve the promise on `uploadcomplete`
      reject the promise on `uploaderror`

      upload the html5 file to the folderId's URL

    else if treeNode is a directory...
      use the Service to add a folder with
       parentFolderId set to folderId
      ...
      during the Service callback...
        create a directory reader

        read entries...
          recursive call: uploadFileTree with entries
           and our new folderId from the response
          ...
          resolve all promises that are mapped to
           entries, and once all promises are resolved
           resolve the *(first Promise)*
*/
}