diff --git a/src/jio.storage/s3storage.js b/src/jio.storage/s3storage.js index 18ed4d35d280b708bd8f82ef2e8c75b00f2b47c1..6bd4a8493769274f450bd84c248e76cc8b7f8773 100644 --- a/src/jio.storage/s3storage.js +++ b/src/jio.storage/s3storage.js @@ -872,9 +872,12 @@ jIO.addStorageType("s3", function (spec, my) { requestUTC, parse, checkCounter; + keys = $(mon_document).find('Key'); + resultTable = []; counter = 0; + keys.each(function (index) { var that, filename, docId; that = $(this); @@ -899,6 +902,7 @@ jIO.addStorageType("s3", function (spec, my) { //needed to save the index within the $.ajax.success() callback count = resultTable.length - 1; countB = 0; + dealCallback = function (i, countB, allDoc) { return function (doc, statustext, response) { allDoc.rows[i].doc = response.responseText; @@ -925,13 +929,16 @@ jIO.addStorageType("s3", function (spec, my) { }; i = resultTable.length - 1; + if (command.getOption("include_docs") === true) { + for (i; i >= 0; i -= 1) { keyId = resultTable[i]; Signature = that.encodeAuthorization(keyId); callURL = 'http://' + priv.server + '.s3.amazonaws.com/' + keyId; requestUTC = new Date().toUTCString(); parse = true; + allDocResponse.rows[i] = { "id": priv.fileNameToIds(keyId).join(), "key": keyId, @@ -980,6 +987,7 @@ jIO.addStorageType("s3", function (spec, my) { //XHRwrapper(command,'PUT','text/plain; charset=UTF-8',true); that.XHRwrapper(command, '', '', 'GET', mime, '', false, false, function (reponse) { + console.log(reponse); mon_document = reponse; makeJSON(); } @@ -990,47 +998,4 @@ jIO.addStorageType("s3", function (spec, my) { //fin alldocs }; return that; -}); - - /* - // It is not possible to attach listeners to xhr level 2 events - // AND validate the Qunit tests through sinon.js - // therefore, below methods are deprecated - - var S3specifics = {}; - - S3specifics.uploadProgress = function(evt){ - if (evt.lengthComputable) { - var percentComplete = Math.round(evt.loaded * 100 / evt.total); - console.log(percentComplete.toString() + '%'); - } else { - console.log('Unable to compute.'); - } - }; - - S3specifics.uploadComplete = function(evt){ - var evt_txt = evt.target.responseText; - var parser = new DOMParser(); - var xmlDoc = parser.parseFromString(evt_txt, "text/xml"); - var responseURL = $(xmlDoc.getElementsByTagName('Location'))[0].text(); - console.log(responseURL); - }; - - S3specifics.uploadFailed = function(evt){ - var evt_txt = evt.target.responseText; - console.log("Erreur lors de la tentative d'upload : " + evt_txt); - }; - - S3specifics.uploadCanceled = function(evt){ - console.log("Upload annulé par l'utilisateur ou le navigateur."); - }; - - S3specifics.onReadyStateChange = function(req, those, that) { - if (req.readyState === 4 && those.status === 200){ - that.success({ - ok: true, - id: command.getDocId() - }); - } - }; - */ +}); \ No newline at end of file diff --git a/test/jiotests.js b/test/jiotests.js index f308584b5c5595a8fa8b458385ae95e6a8f15695..335360c98727e4a8bf31802e924609c1bb6ce5c5 100644 --- a/test/jiotests.js +++ b/test/jiotests.js @@ -7127,7 +7127,7 @@ test ("AllDocs", function(){ ); o.server.respondWith("GET", - "https://jiobucket.s3.amazonaws.com/documentONE", + "http://jiobucket.s3.amazonaws.com/documentONE", [ 200, {"Content-Type": "text/html"}, @@ -7148,8 +7148,11 @@ test ("AllDocs", function(){ ] ); + console.log(o); + o.spy(o, "jobstatus", "done", "AllDocs with include docs"); o.jio.allDocs({"include_docs": true},o.f); + console.log(o.f); o.clock.tick(5000); o.server.respond(); o.tick(o);