WinJS Promise based file upload queue
问题 Scenario I need a background upload queue that sends files to a server. The queue should send the files in sequential order as they are pushed into the queue (FIFO). My solution var pendingFiles = []; var filesOperation = null; uploadNextAsync = function(file) { var next; if (!pendingFiles.length) { return WinJS.Promise.as(); } next = pendingFiles.shift(); fileslogger.debug("Uploading " + next); return fileQuery.folder.getFileAsync(next).then(function(file) { return Server.sendFileAsync(file)