Skip to content

Commit 2bf91b6

Browse files
committed
make storage getUrl configurable
1 parent fbfb526 commit 2bf91b6

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

js/embark.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,10 @@ EmbarkJS.Storage.setProvider = function(provider, options) {
208208
try {
209209
if (options === undefined) {
210210
self.ipfsConnection = IpfsApi('localhost', '5001');
211+
self.getUrl = "http://localhost:8080/ipfs/";
211212
} else {
212213
self.ipfsConnection = IpfsApi(options.server, options.port);
214+
self.getUrl = options.getUrl || "http://localhost:8080/ipfs/";
213215
}
214216
resolve(self);
215217
} catch (err) {
@@ -301,7 +303,8 @@ EmbarkJS.Storage.IPFS.uploadFile = function(inputSelector) {
301303
EmbarkJS.Storage.IPFS.getUrl = function(hash) {
302304
//var ipfsHash = web3.toAscii(hash);
303305

304-
return 'http://localhost:8080/ipfs/' + hash;
306+
//return 'http://localhost:8080/ipfs/' + hash;
307+
return (self.getUrl || "http://localhost:8080/ipfs/") + hash;
305308
};
306309

307310
//=========================================================

lib/contracts/abi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ class ABIGenerator {
158158
if (!useEmbarkJS || self.storageConfig === {}) return "";
159159

160160
if (self.storageConfig.provider === 'ipfs' && self.storageConfig.enabled === true) {
161-
result += "\nEmbarkJS.Storage.setProvider('" + self.storageConfig.provider + "', {server: '" + self.storageConfig.host + "', port: '" + self.storageConfig.port + "'});";
161+
// TODO: make this more readable
162+
result += "\nEmbarkJS.Storage.setProvider('" + self.storageConfig.provider + "', {server: '" + self.storageConfig.host + "', port: '" + self.storageConfig.port + "', getUrl: '" + self.storageConfig.getUrl + "'});";
162163
}
163164

164165
return result;

lib/core/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ Config.prototype.loadStorageConfigFile = function() {
119119
"ipfs_bin": "ipfs",
120120
"provider": "ipfs",
121121
"host": "localhost",
122-
"port": 5001
122+
"port": 5001,
123+
"getUrl": "http://localhost:8080/ipfs/"
123124
},
124125
"development": {
125126
}

test_app/config/storage.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"enabled": true,
1212
"provider": "ipfs",
1313
"host": "localhost",
14-
"port": 5001
14+
"port": 5001,
15+
"getUrl": "http://localhost:8080/ipfs/"
1516
}
1617
}

0 commit comments

Comments
 (0)