1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

remove fs because it does not work in the browser

This commit is contained in:
Sebastian Gerske 2018-12-10 13:26:33 +01:00
parent 83ce375588
commit ce009dcd94

View File

@ -1,3 +1,4 @@
import {saveAs} from "file-saver"
import AquariusProvider from "../aquarius/AquariusProvider"
import SearchQuery from "../aquarius/query/SearchQuery"
import BrizoProvider from "../brizo/BrizoProvider"
@ -24,8 +25,6 @@ import ServiceAgreement from "./ServiceAgreements/ServiceAgreement"
import ServiceAgreementTemplate from "./ServiceAgreements/ServiceAgreementTemplate"
import Access from "./ServiceAgreements/Templates/Access"
import * as fs from "fs"
import EventListener from "../keeper/EventListener"
import WebServiceConnectorProvider from "../utils/WebServiceConnectorProvider"
@ -210,20 +209,9 @@ export default class Ocean {
const parts: string[] = cUrl.split("/")
const filename: string = parts[parts.length - 1]
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)
const target = `${__dirname}/downloads/${filename}`
await saveAs([buffer.toString("utf8")], filename)
Logger.log("saved file to:", target)
}
Logger.log("Done downloading asset files.")
})