support setting protocol in config; fix getUrl

This commit is contained in:
Iuri Matias 2018-03-02 16:57:55 -05:00
parent bde067aabf
commit 13e759bfee
3 changed files with 11 additions and 2 deletions

View File

@ -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;
};

View File

@ -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 + ");";

View File

@ -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/"
}
}