From 0945bcf43572b625bea4c0432d072ad5c0608bf7 Mon Sep 17 00:00:00 2001 From: Jirka Chadima Date: Mon, 25 Jun 2018 15:31:05 +0200 Subject: [PATCH 1/2] Replaces deprecated bzzr protocol with bzz-raw --- src/swarm.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/swarm.js b/src/swarm.js index 5d5ae39..d1f2368 100644 --- a/src/swarm.js +++ b/src/swarm.js @@ -56,7 +56,7 @@ module.exports = ({ // String -> String -> String const rawUrl = swarmUrl => hash => - `${swarmUrl}/bzzr:/${hash}` + `${swarmUrl}/bzz-raw:/${hash}` // String -> String -> Promise Uint8Array // Gets the raw contents of a Swarm hash address. @@ -154,7 +154,7 @@ module.exports = ({ // Uploads raw data to Swarm. // Returns a promise with the uploaded hash. const uploadData = swarmUrl => data => - request(`${swarmUrl}/bzzr:/`, { + request(`${swarmUrl}/bzz-raw:/`, { body: typeof data === "string" ? fromString(data) : data, method: "POST"}); From 84f477d50b4a2f088977ffbc765b14262d713c9a Mon Sep 17 00:00:00 2001 From: Jirka Chadima Date: Thu, 28 Jun 2018 09:15:50 +0200 Subject: [PATCH 2/2] chore: Rebuilds the whole thing --- examples/example_dapp_uploader/swarm.min.js | 29 +++++++++++++++++++++ lib/files.js | 21 ++++++++------- lib/swarm.js | 6 ++--- 3 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 examples/example_dapp_uploader/swarm.min.js diff --git a/examples/example_dapp_uploader/swarm.min.js b/examples/example_dapp_uploader/swarm.min.js new file mode 100644 index 0000000..d19d954 --- /dev/null +++ b/examples/example_dapp_uploader/swarm.min.js @@ -0,0 +1,29 @@ +var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,e,f){a!=Array.prototype&&a!=Object.prototype&&(a[e]=f.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_"; +$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var a=0;return function(e){return $jscomp.SYMBOL_PREFIX+(e||"")+a++}}(); +$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var e=0;return $jscomp.iteratorPrototype(function(){return e Promise Bool var isDirectory = function isDirectory(path) { - return fs.exists(path).then(assert).then(function () { - return fs.lstat(path); + return fsp.exists(path).then(assert).then(function () { + return fsp.lstat(path); }).then(function (stats) { return stats.isDirectory(); }).catch(function () { @@ -124,7 +125,7 @@ var directoryTree = function directoryTree(dirPath) { var searchOnDir = function searchOnDir(dir) { return search(path.join(dirPath, dir)); }; - return Q.all(Q.map(fs.readdir(dirPath), searchOnDir)); + return Q.all(Q.map(fsp.readdir(dirPath), searchOnDir)); } else { paths.push(dirPath); }; @@ -164,8 +165,8 @@ var safeDownloadArchived = function safeDownloadArchived(url) { }).then(function () { return filePath; }).catch(function () { - return fs.exists(archiveDir).then(function (exists) { - return !exists ? fs.mkdir(archiveDir) : null; + return fsp.exists(archiveDir).then(function (exists) { + return !exists ? fsp.mkdir(archiveDir) : null; }).then(function () { return download(url)(archivePath).onData(promise.onDataCallback); }).then(function () { @@ -177,9 +178,9 @@ var safeDownloadArchived = function safeDownloadArchived(url) { }).then(function () { return search(new RegExp(fileName + "$"))(archiveDir); }).then(function (fp) { - return fs.rename(fp[0], filePath); + return fsp.rename(fp[0], filePath); }).then(function () { - return fs.unlink(archivePath); + return fsp.unlink(archivePath); }).then(function () { return fileHash ? checksum(fileHash)(filePath) : null; }).then(function () { @@ -247,4 +248,4 @@ module.exports = { downloadArchived: downloadArchived, search: search, test: test -}; +}; \ No newline at end of file diff --git a/lib/swarm.js b/lib/swarm.js index 43bba4a..f6e4e2a 100644 --- a/lib/swarm.js +++ b/lib/swarm.js @@ -68,7 +68,7 @@ module.exports = function (_ref) { // String -> String -> String var rawUrl = function rawUrl(swarmUrl) { return function (hash) { - return swarmUrl + "/bzzr:/" + hash; + return swarmUrl + "/bzz-raw:/" + hash; }; }; @@ -206,7 +206,7 @@ module.exports = function (_ref) { // Returns a promise with the uploaded hash. var uploadData = function uploadData(swarmUrl) { return function (data) { - return request(swarmUrl + "/bzzr:/", { + return request(swarmUrl + "/bzz-raw:/", { body: typeof data === "string" ? fromString(data) : data, method: "POST" }); }; @@ -622,4 +622,4 @@ module.exports = function (_ref) { fromString: fromString, toString: toString }; -}; +}; \ No newline at end of file