Commit 00ad6db5 authored by Tristan Cavelier's avatar Tristan Cavelier

s3storage.js amd compatible now

parent 3865c36d
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global jIO: true, btoa: true, b64_hmac_sha1: true */ /*global define, jIO, btoa, b64_hmac_sha1, jQuery, XMLHttpRequest, XHRwrapper,
/*global XMLHttpRequest: true, XHRwrapper: true, FormData: true, $: true*/ FormData*/
/** /**
* JIO S3 Storage. Type = "s3". * JIO S3 Storage. Type = "s3".
* Amazon S3 "database" storage. * Amazon S3 "database" storage.
*/ */
jIO.addStorageType("s3", function (spec, my) { // define([module_name], [dependencies], module);
(function (dependencies, module) {
"use strict";
if (typeof define === 'function' && define.amd) {
return define(dependencies, module);
}
module(jIO, jQuery, {b64_hmac_sha1: b64_hmac_sha1});
}(['jio', 'jquery', 'sha1'], function (jIO, $, sha1) {
var b64_hmac_sha1 = sha1.b64_hmac_sha1;
jIO.addStorageType("s3", function (spec, my) {
var evt, that, priv = {}; var evt, that, priv = {};
spec = spec || {}; spec = spec || {};
that = my.basicStorage(spec, my); that = my.basicStorage(spec, my);
...@@ -288,7 +298,8 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -288,7 +298,8 @@ jIO.addStorageType("s3", function (spec, my) {
obj.onreadystatechange = function () { obj.onreadystatechange = function () {
var response, err = ''; var response, err = '';
if (obj.readyState === 4) { if (obj.readyState === 4) {
if (this.status === 204 || this.status === 201 || this.status === 200) { if (this.status === 204 || this.status === 201 ||
this.status === 200) {
switch (http) { switch (http) {
case "POST": case "POST":
that.success({ that.success({
...@@ -809,8 +820,8 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -809,8 +820,8 @@ jIO.addStorageType("s3", function (spec, my) {
attachment_length = command.getAttachmentLength(); attachment_length = command.getAttachmentLength();
function removeAttachment() { function removeAttachment() {
that.XHRwrapper(command, docId, attachId, 'DELETE', mime, '', true, true, that.XHRwrapper(command, docId, attachId, 'DELETE', mime, '', true,
function (reponse) { true, function (reponse) {
} }
); );
} }
...@@ -988,4 +999,6 @@ jIO.addStorageType("s3", function (spec, my) { ...@@ -988,4 +999,6 @@ jIO.addStorageType("s3", function (spec, my) {
//fin alldocs //fin alldocs
}; };
return that; return that;
}); });
}));
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