diff --git a/package.json b/package.json index d518620..3674063 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,6 @@ "eth-crypto": "^1.2.7", "eth-ecies": "^1.0.3", "ethereumjs-util": "^6.0.0", - "file-saver": "^2.0.0", "jsonwebtoken": "^8.4.0", "node-fetch": "^2.3.0", "uuid": "^3.3.2", diff --git a/src/examples/InitializeAgreement.ts b/src/examples/InitializeAgreement.ts index 3c77705..ef541e8 100644 --- a/src/examples/InitializeAgreement.ts +++ b/src/examples/InitializeAgreement.ts @@ -8,7 +8,7 @@ import * as config from "./config.json" (async () => { const ocean: Ocean = await Ocean.getInstance(config) - const publisher: Account = (await ocean.getAccounts())[0] + const publisher: Account = (await ocean.getAccounts())[1] const consumer: Account = (await ocean.getAccounts())[1] const metaData = new MetaData({ diff --git a/src/examples/config.json b/src/examples/config.json index f6efecd..54d38c4 100644 --- a/src/examples/config.json +++ b/src/examples/config.json @@ -1,10 +1,10 @@ { "nodeUri": "http://localhost:8545", - "aquariusUri": "http://localhost:5000", - "brizoUri": "http://localhost:8030", + "aquariusUri": "http://172.15.0.15:5000", + "brizoUri": "http://172.15.0.17:8030", "parityUri": "http://localhost:8545", "secretStoreUri": "http://localhost:12001", "threshold": 0, - "password": "secret", - "address": "0xa99d43d86a0758d5632313b8fa3972b6088a21bb" + "password": "node0", + "address": "0x00bd138abd70e2f00903268f3db08f2d25677c9e" } diff --git a/src/ocean/Ocean.ts b/src/ocean/Ocean.ts index 5f2fdae..7d7600c 100644 --- a/src/ocean/Ocean.ts +++ b/src/ocean/Ocean.ts @@ -24,7 +24,7 @@ import ServiceAgreement from "./ServiceAgreements/ServiceAgreement" import ServiceAgreementTemplate from "./ServiceAgreements/ServiceAgreementTemplate" import Access from "./ServiceAgreements/Templates/Access" -import { saveAs } from "file-saver" +import * as fs from "fs" import EventListener from "../keeper/EventListener" import WebServiceConnectorProvider from "../utils/WebServiceConnectorProvider" @@ -206,13 +206,23 @@ export default class Ocean { url = url + `&consumerAddress=${consumer.getId()}` Logger.log("Fetching asset from: ", url) const response: any = await webConnector.get(url) - const blob: object = await response.blob() - // Logger.log("response: ", response.headers, response) + const buffer: Buffer = await response.buffer() const parts: string[] = cUrl.split("/") const filename: string = parts[parts.length - 1] - Logger.log("got blob: ", filename, blob) - // :FIXME: this does not save the file, debug and fix - saveAs(blob, "./downloads/" + filename) + Logger.debug(`Got response: filename is ${filename}, url is ${response.url}`) + fs.open("./downloads/" + filename, "w", (err, fd) => { + if (err) { + throw Error("error opening file for writing." + err) + } + fs.write(fd, buffer, 0, buffer.length, null, (writeErr) => { + if (err) { + throw Error("error writing file: " + writeErr) + } + fs.close(fd, () => { + Logger.debug("file written.") + }) + }) + }) Logger.log("saved file to:", "./downloads/" + filename) } Logger.log("Done downloading asset files.")