Skip to content

Instantly share code, notes, and snippets.

@marclundgren
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marclundgren/6a6db0bd262326e61d52 to your computer and use it in GitHub Desktop.
Save marclundgren/6a6db0bd262326e61d52 to your computer and use it in GitHub Desktop.
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)*
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment