diff --git a/package.json b/package.json index 413db75db0..e3383397de 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "expose-loader": "~0.7.5", "form-data": "^2.3.2", "hat": "0.0.3", - "interface-ipfs-core": "~0.68.2", + "interface-ipfs-core": "~0.69.0", "ipfsd-ctl": "~0.37.3", "lodash": "^4.17.10", "mocha": "^5.1.1", @@ -107,7 +107,7 @@ "hoek": "^5.0.3", "human-to-milliseconds": "^1.0.0", "interface-datastore": "^0.4.1", - "ipfs-api": "^22.0.0", + "ipfs-api": "^22.1.1", "ipfs-bitswap": "~0.20.0", "ipfs-block": "~0.7.1", "ipfs-block-service": "~0.14.0", diff --git a/src/core/components/pin.js b/src/core/components/pin.js index 93f79a8e74..b9a60b7f75 100644 --- a/src/core/components/pin.js +++ b/src/core/components/pin.js @@ -92,7 +92,7 @@ module.exports = function pin (self) { }), // hack for CLI tests - cb => repo.closed ? repo.datastore.open(cb) : cb(null, null), + cb => repo.closed ? repo.open(cb) : cb(null, null), // save root to datastore under a consistent key cb => repo.datastore.put(pinDataStoreKey, root.multihash, cb) diff --git a/src/http/api/resources/block.js b/src/http/api/resources/block.js index f536fb2a22..1bae34fd8d 100644 --- a/src/http/api/resources/block.js +++ b/src/http/api/resources/block.js @@ -49,8 +49,9 @@ exports.get = { } if (block) { - return reply(block.data) + return reply(block.data).header('X-Stream-Output', '1') } + return reply({ Message: 'Block was unwanted before it could be remotely retrieved', Code: 0 @@ -63,32 +64,40 @@ exports.put = { // pre request handler that parses the args and returns `data` which is assigned to `request.pre.args` parseArgs: (request, reply) => { if (!request.payload) { - return reply("File argument 'data' is required").code(400).takeover() + return reply({ + Message: "File argument 'data' is required", + Code: 0 + }).code(400).takeover() } const parser = multipart.reqParser(request.payload) var file parser.on('file', (fileName, fileStream) => { + file = Buffer.alloc(0) + fileStream.on('data', (data) => { - file = data + file = Buffer.concat([file, data]) }) }) parser.on('end', () => { if (!file) { - return reply("File argument 'data' is required").code(400).takeover() + return reply({ + Message: "File argument 'data' is required", + Code: 0 + }).code(400).takeover() } return reply({ - data: file.toString() + data: file }) }) }, // main route handler which is called after the above `parseArgs`, but only if the args were valid handler: (request, reply) => { - const data = Buffer.from(request.pre.args.data) + const data = request.pre.args.data const ipfs = request.server.app.ipfs waterfall([