From 13e759bfee27d7b5f330c66fdf09d8bda919dc36 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 2 Mar 2018 16:57:55 -0500 Subject: [PATCH] support setting protocol in config; fix getUrl --- lib/modules/ipfs/embarkjs.js | 4 ++-- lib/modules/ipfs/index.js | 1 + test_app/config/storage.json | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/modules/ipfs/embarkjs.js b/lib/modules/ipfs/embarkjs.js index 53e18567..0412babd 100644 --- a/lib/modules/ipfs/embarkjs.js +++ b/lib/modules/ipfs/embarkjs.js @@ -14,7 +14,7 @@ __embarkIPFS.setProvider = function(options) { if (options.protocol) { ipfsOptions.protocol = options.protocol; } - if (options.port) { + if (options.port && options.port !== 'false') { ipfsOptions.port = options.port; } self.ipfsConnection = IpfsApi(ipfsOptions); @@ -100,6 +100,6 @@ __embarkIPFS.uploadFile = function(inputSelector) { }; __embarkIPFS.getUrl = function(hash) { - return (self._getUrl || "http://localhost:8080/ipfs/") + hash; + return (this._getUrl || "http://localhost:8080/ipfs/") + hash; }; diff --git a/lib/modules/ipfs/index.js b/lib/modules/ipfs/index.js index 2a09d03c..e0f03a44 100644 --- a/lib/modules/ipfs/index.js +++ b/lib/modules/ipfs/index.js @@ -96,6 +96,7 @@ class IPFS { let config = JSON.stringify({ server: this.storageConfig.host, port: this.storageConfig.port, + protocol: this.storageConfig.protocol, getUrl: this.storageConfig.getUrl }); let code = "\nEmbarkJS.Storage.setProvider('ipfs'," + config + ");"; diff --git a/test_app/config/storage.json b/test_app/config/storage.json index a21b4cde..5492ed28 100644 --- a/test_app/config/storage.json +++ b/test_app/config/storage.json @@ -16,5 +16,13 @@ "host": "localhost", "port": 5001, "getUrl": "http://localhost:8080/ipfs/" + }, + "livenet": { + "enabled": true, + "provider": "ipfs", + "host": "ipfs.infura.io", + "protocol": "https", + "port": false, + "getUrl": "https://ipfs.infura.io/ipfs/" } }