diff --git a/examples/scenario.js b/examples/scenario.js index f0772f63dc933be66be8b821f5561ac8d67944c4..6aa76d0cc8524b46cb575dc0ee8038792f9eaff2 100644 --- a/examples/scenario.js +++ b/examples/scenario.js @@ -93,7 +93,8 @@ // type: "drivetojiomapping", // sub_storage: { // "type": "dropbox", -// "access_token" : "TOKEN" +// "access_token" : "TOKEN", +// "root" : "dropbox" // } // } // } diff --git a/src/jio.storage/dropboxstorage.js b/src/jio.storage/dropboxstorage.js index 2e31b9c0c320061aa62ee14c2eb051fd82a2a331..66ffc1afd919ca2f9ea6cff9f0047218a9369e21 100644 --- a/src/jio.storage/dropboxstorage.js +++ b/src/jio.storage/dropboxstorage.js @@ -49,8 +49,12 @@ throw new TypeError("Access Token' must be a string " + "which contains more than one character."); } + if (typeof spec.root !== 'string' || !spec.root || + (spec.root !== "dropbox" && spec.root !== "sandbox")) { + throw new TypeError("root must be 'dropbox' or 'sandbox'"); + } this._access_token = spec.access_token; - this._root = "dropbox"; + this._root = spec.root; } DropboxStorage.prototype.put = function (id, param) { diff --git a/test/jio.storage/dropboxstorage.tests.js b/test/jio.storage/dropboxstorage.tests.js index a81c9787ce92bd0ca1e12413b3f3d2efd2b7187c..05dff974fa5305a72b6febdadec143d62a8790c5 100644 --- a/test/jio.storage/dropboxstorage.tests.js +++ b/test/jio.storage/dropboxstorage.tests.js @@ -20,7 +20,8 @@ test("create storage", function () { var jio = jIO.createJIO({ type: "dropbox", - access_token: token + access_token: token, + root : "dropbox" }); equal(jio.__type, "dropbox"); deepEqual(jio.__storage._access_token, token); @@ -38,7 +39,8 @@ this.jio = jIO.createJIO({ type: "dropbox", - access_token: token + access_token: token, + root : "dropbox" }); }, teardown: function () { @@ -166,7 +168,8 @@ this.jio = jIO.createJIO({ type: "dropbox", - access_token: token + access_token: token, + root : "dropbox" }); }, teardown: function () { @@ -264,7 +267,8 @@ this.jio = jIO.createJIO({ type: "dropbox", - access_token: token + access_token: token, + root : "dropbox" }); }, teardown: function () { @@ -366,7 +370,8 @@ this.jio = jIO.createJIO({ type: "dropbox", - access_token: token + access_token: token, + root : "dropbox" }); }, teardown: function () { @@ -507,7 +512,8 @@ this.jio = jIO.createJIO({ type: "dropbox", - access_token: token + access_token: token, + root : "dropbox" }); }, teardown: function () { @@ -679,7 +685,8 @@ this.jio = jIO.createJIO({ type: "dropbox", - access_token: token + access_token: token, + root : "dropbox" }); }, teardown: function () { @@ -840,7 +847,8 @@ this.jio = jIO.createJIO({ type: "dropbox", - access_token: token + access_token: token, + root : "dropbox" }); }, teardown: function () {