mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-23 05:38:52 +00:00
fix ipfs methods
This commit is contained in:
parent
a8b9630b99
commit
fe926382ce
@ -121,7 +121,7 @@ var EmbarkJS =
|
|||||||
EmbarkJS.Storage.setProvider = function(provider, options) {
|
EmbarkJS.Storage.setProvider = function(provider, options) {
|
||||||
if (provider === 'ipfs') {
|
if (provider === 'ipfs') {
|
||||||
this.currentStorage = EmbarkJS.Storage.IPFS;
|
this.currentStorage = EmbarkJS.Storage.IPFS;
|
||||||
this.ipfsConnection = Ipfs(options.server, options.port);
|
this.ipfsConnection = IpfsApi(options.server, options.port);
|
||||||
} else {
|
} else {
|
||||||
throw Error('unknown provider');
|
throw Error('unknown provider');
|
||||||
}
|
}
|
||||||
@ -167,10 +167,11 @@ var EmbarkJS =
|
|||||||
|
|
||||||
EmbarkJS.Storage.get = function(hash) {
|
EmbarkJS.Storage.get = function(hash) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var ipfsHash = this.web3.toAscii(hash);
|
// TODO: detect type, then convert if needed
|
||||||
|
//var ipfsHash = web3.toAscii(hash);
|
||||||
|
|
||||||
var promise = new Promise(function(resolve, reject) {
|
var promise = new Promise(function(resolve, reject) {
|
||||||
self.ipfsConnection.object.get([ipfsHash]).then(function(node) {
|
self.ipfsConnection.object.get([hash]).then(function(node) {
|
||||||
resolve(node.data);
|
resolve(node.data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -179,10 +180,9 @@ var EmbarkJS =
|
|||||||
};
|
};
|
||||||
|
|
||||||
EmbarkJS.Storage.getUrl = function(hash) {
|
EmbarkJS.Storage.getUrl = function(hash) {
|
||||||
var self = this;
|
//var ipfsHash = web3.toAscii(hash);
|
||||||
var ipfsHash = web3.toAscii(hash);
|
|
||||||
|
|
||||||
return 'http://localhost:8080/ipfs/' + ipfsHash;
|
return 'http://localhost:8080/ipfs/' + hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
EmbarkJS.Messages = {
|
EmbarkJS.Messages = {
|
||||||
|
12
js/embark.js
12
js/embark.js
@ -74,7 +74,7 @@ EmbarkJS.Storage = {
|
|||||||
EmbarkJS.Storage.setProvider = function(provider, options) {
|
EmbarkJS.Storage.setProvider = function(provider, options) {
|
||||||
if (provider === 'ipfs') {
|
if (provider === 'ipfs') {
|
||||||
this.currentStorage = EmbarkJS.Storage.IPFS;
|
this.currentStorage = EmbarkJS.Storage.IPFS;
|
||||||
this.ipfsConnection = Ipfs(options.server, options.port);
|
this.ipfsConnection = IpfsApi(options.server, options.port);
|
||||||
} else {
|
} else {
|
||||||
throw Error('unknown provider');
|
throw Error('unknown provider');
|
||||||
}
|
}
|
||||||
@ -120,10 +120,11 @@ EmbarkJS.Storage.uploadFile = function(inputSelector) {
|
|||||||
|
|
||||||
EmbarkJS.Storage.get = function(hash) {
|
EmbarkJS.Storage.get = function(hash) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var ipfsHash = this.web3.toAscii(hash);
|
// TODO: detect type, then convert if needed
|
||||||
|
//var ipfsHash = web3.toAscii(hash);
|
||||||
|
|
||||||
var promise = new Promise(function(resolve, reject) {
|
var promise = new Promise(function(resolve, reject) {
|
||||||
self.ipfsConnection.object.get([ipfsHash]).then(function(node) {
|
self.ipfsConnection.object.get([hash]).then(function(node) {
|
||||||
resolve(node.data);
|
resolve(node.data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -132,10 +133,9 @@ EmbarkJS.Storage.get = function(hash) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EmbarkJS.Storage.getUrl = function(hash) {
|
EmbarkJS.Storage.getUrl = function(hash) {
|
||||||
var self = this;
|
//var ipfsHash = web3.toAscii(hash);
|
||||||
var ipfsHash = web3.toAscii(hash);
|
|
||||||
|
|
||||||
return 'http://localhost:8080/ipfs/' + ipfsHash;
|
return 'http://localhost:8080/ipfs/' + hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
EmbarkJS.Messages = {
|
EmbarkJS.Messages = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user