Commit 96cbccb1 authored by Tristan Cavelier's avatar Tristan Cavelier

Merge remote-tracking branch 's3/master'

Conflicts:
	src/jio.storage/s3storage.js
	test/jiotests.js
parents ac7b4ae5 89d30927
...@@ -15,8 +15,6 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -15,8 +15,6 @@ jIO.addStorageType("s3", function (spec, my) {
priv.AWSIdentifier = spec.AWSIdentifier || ''; priv.AWSIdentifier = spec.AWSIdentifier || '';
priv.password = spec.password || ''; priv.password = spec.password || '';
priv.server = spec.server || ''; /*|| jiobucket ||*/ priv.server = spec.server || ''; /*|| jiobucket ||*/
priv.url = spec.url || ''; /*||> https://s3-eu-west-1.amazonaws.com <||*/
priv.acl = spec.acl || ''; priv.acl = spec.acl || '';
/*||> "private, /*||> "private,
...@@ -194,7 +192,6 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -194,7 +192,6 @@ jIO.addStorageType("s3", function (spec, my) {
return { return {
"username": priv.username, "username": priv.username,
"password": priv.password, "password": priv.password,
"url": priv.url,
"server": priv.server, "server": priv.server,
"acl": priv.acl "acl": priv.acl
}; };
...@@ -210,9 +207,6 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -210,9 +207,6 @@ jIO.addStorageType("s3", function (spec, my) {
if (typeof priv.password === "string" && priv.password === '') { if (typeof priv.password === "string" && priv.password === '') {
return 'Need at least one parameter "password".'; return 'Need at least one parameter "password".';
} }
if (typeof priv.url === "string" && priv.url === '') {
return 'Need at least one parameter "url".';
}
if (typeof priv.server === "string" && priv.server === '') { if (typeof priv.server === "string" && priv.server === '') {
return 'Need at least one parameter "server".'; return 'Need at least one parameter "server".';
} }
...@@ -415,9 +409,7 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -415,9 +409,7 @@ jIO.addStorageType("s3", function (spec, my) {
doc = JSON.stringify(doc); doc = JSON.stringify(doc);
break; break;
case "update": case "update":
console.log(doc._attachments);
doc._attachments[attachid] = data; doc._attachments[attachid] = data;
console.log(doc._attachments);
//update happened in the put request //update happened in the put request
doc = JSON.stringify(doc); doc = JSON.stringify(doc);
break; break;
...@@ -872,9 +864,12 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -872,9 +864,12 @@ jIO.addStorageType("s3", function (spec, my) {
requestUTC, requestUTC,
parse, parse,
checkCounter; checkCounter;
keys = $(mon_document).find('Key'); keys = $(mon_document).find('Key');
resultTable = []; resultTable = [];
counter = 0; counter = 0;
keys.each(function (index) { keys.each(function (index) {
var that, filename, docId; var that, filename, docId;
that = $(this); that = $(this);
...@@ -899,6 +894,7 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -899,6 +894,7 @@ jIO.addStorageType("s3", function (spec, my) {
//needed to save the index within the $.ajax.success() callback //needed to save the index within the $.ajax.success() callback
count = resultTable.length - 1; count = resultTable.length - 1;
countB = 0; countB = 0;
dealCallback = function (i, countB, allDoc) { dealCallback = function (i, countB, allDoc) {
return function (doc, statustext, response) { return function (doc, statustext, response) {
allDoc.rows[i].doc = response.responseText; allDoc.rows[i].doc = response.responseText;
...@@ -925,13 +921,16 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -925,13 +921,16 @@ jIO.addStorageType("s3", function (spec, my) {
}; };
i = resultTable.length - 1; i = resultTable.length - 1;
if (command.getOption("include_docs") === true) { if (command.getOption("include_docs") === true) {
for (i; i >= 0; i -= 1) { for (i; i >= 0; i -= 1) {
keyId = resultTable[i]; keyId = resultTable[i];
Signature = that.encodeAuthorization(keyId); Signature = that.encodeAuthorization(keyId);
callURL = priv.url + keyId; callURL = 'http://' + priv.server + '.s3.amazonaws.com/' + keyId;
requestUTC = new Date().toUTCString(); requestUTC = new Date().toUTCString();
parse = true; parse = true;
allDocResponse.rows[i] = { allDocResponse.rows[i] = {
"id": priv.fileNameToIds(keyId).join(), "id": priv.fileNameToIds(keyId).join(),
"key": keyId, "key": keyId,
...@@ -950,7 +949,6 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -950,7 +949,6 @@ jIO.addStorageType("s3", function (spec, my) {
+ priv.AWSIdentifier + priv.AWSIdentifier
+ ":" + ":"
+ Signature, + Signature,
//'Host' : priv.url,
'x-amz-date' : requestUTC, 'x-amz-date' : requestUTC,
'Content-Type' : 'application/json' 'Content-Type' : 'application/json'
//'Content-MD5' : '' //'Content-MD5' : ''
...@@ -991,46 +989,3 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -991,46 +989,3 @@ jIO.addStorageType("s3", function (spec, my) {
}; };
return that; 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()
});
}
};
*/
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment