make storage getUrl configurable
This commit is contained in:
parent
fbfb5269b0
commit
2bf91b6d9a
|
@ -208,8 +208,10 @@ EmbarkJS.Storage.setProvider = function(provider, options) {
|
||||||
try {
|
try {
|
||||||
if (options === undefined) {
|
if (options === undefined) {
|
||||||
self.ipfsConnection = IpfsApi('localhost', '5001');
|
self.ipfsConnection = IpfsApi('localhost', '5001');
|
||||||
|
self.getUrl = "http://localhost:8080/ipfs/";
|
||||||
} else {
|
} else {
|
||||||
self.ipfsConnection = IpfsApi(options.server, options.port);
|
self.ipfsConnection = IpfsApi(options.server, options.port);
|
||||||
|
self.getUrl = options.getUrl || "http://localhost:8080/ipfs/";
|
||||||
}
|
}
|
||||||
resolve(self);
|
resolve(self);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -301,7 +303,8 @@ EmbarkJS.Storage.IPFS.uploadFile = function(inputSelector) {
|
||||||
EmbarkJS.Storage.IPFS.getUrl = function(hash) {
|
EmbarkJS.Storage.IPFS.getUrl = function(hash) {
|
||||||
//var ipfsHash = web3.toAscii(hash);
|
//var ipfsHash = web3.toAscii(hash);
|
||||||
|
|
||||||
return 'http://localhost:8080/ipfs/' + hash;
|
//return 'http://localhost:8080/ipfs/' + hash;
|
||||||
|
return (self.getUrl || "http://localhost:8080/ipfs/") + hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
//=========================================================
|
//=========================================================
|
||||||
|
|
|
@ -158,7 +158,8 @@ class ABIGenerator {
|
||||||
if (!useEmbarkJS || self.storageConfig === {}) return "";
|
if (!useEmbarkJS || self.storageConfig === {}) return "";
|
||||||
|
|
||||||
if (self.storageConfig.provider === 'ipfs' && self.storageConfig.enabled === true) {
|
if (self.storageConfig.provider === 'ipfs' && self.storageConfig.enabled === true) {
|
||||||
result += "\nEmbarkJS.Storage.setProvider('" + self.storageConfig.provider + "', {server: '" + self.storageConfig.host + "', port: '" + self.storageConfig.port + "'});";
|
// TODO: make this more readable
|
||||||
|
result += "\nEmbarkJS.Storage.setProvider('" + self.storageConfig.provider + "', {server: '" + self.storageConfig.host + "', port: '" + self.storageConfig.port + "', getUrl: '" + self.storageConfig.getUrl + "'});";
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -119,7 +119,8 @@ Config.prototype.loadStorageConfigFile = function() {
|
||||||
"ipfs_bin": "ipfs",
|
"ipfs_bin": "ipfs",
|
||||||
"provider": "ipfs",
|
"provider": "ipfs",
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"port": 5001
|
"port": 5001,
|
||||||
|
"getUrl": "http://localhost:8080/ipfs/"
|
||||||
},
|
},
|
||||||
"development": {
|
"development": {
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"provider": "ipfs",
|
"provider": "ipfs",
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"port": 5001
|
"port": 5001,
|
||||||
|
"getUrl": "http://localhost:8080/ipfs/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue