From d874314dc6b56c4527d4b1b15a9022ae122b8cd2 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 26 Oct 2018 15:08:02 +0200 Subject: [PATCH] feat: update HTTP API and Gateway to use latest Files API --- src/http/api/resources/files.js | 10 +++++----- src/http/api/routes/files.js | 12 ++++++------ src/http/gateway/resources/gateway.js | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/http/api/resources/files.js b/src/http/api/resources/files.js index 3e2fb28d38..0a902d4e4e 100644 --- a/src/http/api/resources/files.js +++ b/src/http/api/resources/files.js @@ -79,13 +79,13 @@ exports.cat = { const options = request.pre.args.options const ipfs = request.server.app.ipfs - ipfs.files.cat(key, options, (err, stream) => { + ipfs.cat(key, options, (err, stream) => { if (err) { log.error(err) if (err.message === 'No such file') { - reply({Message: 'No such file', Code: 0, Type: 'error'}).code(500) + reply({ Message: 'No such file', Code: 0, Type: 'error' }).code(500) } else { - reply({Message: 'Failed to cat file: ' + err, Code: 0, Type: 'error'}).code(500) + reply({ Message: 'Failed to cat file: ' + err, Code: 0, Type: 'error' }).code(500) } return } @@ -113,7 +113,7 @@ exports.get = { const ipfs = request.server.app.ipfs const pack = tar.pack() - ipfs.files.get(cid, (err, filesArray) => { + ipfs.get(cid, (err, filesArray) => { if (err) { log.error(err) pack.emit('error', err) @@ -258,7 +258,7 @@ exports.add = { pull( fileAdder, - ipfs.files.addPullStream(options), + ipfs.addPullStream(options), pull.map((file) => { return { Name: file.path, // addPullStream already turned this into a hash if it wanted to diff --git a/src/http/api/routes/files.js b/src/http/api/routes/files.js index 44b00f9fa8..fca1a68001 100644 --- a/src/http/api/routes/files.js +++ b/src/http/api/routes/files.js @@ -12,9 +12,9 @@ module.exports = (server) => { path: '/api/v0/cat', config: { pre: [ - { method: resources.files.cat.parseArgs, assign: 'args' } + { method: resources.cat.parseArgs, assign: 'args' } ], - handler: resources.files.cat.handler + handler: resources.cat.handler } }) @@ -24,9 +24,9 @@ module.exports = (server) => { path: '/api/v0/get', config: { pre: [ - { method: resources.files.get.parseArgs, assign: 'args' } + { method: resources.get.parseArgs, assign: 'args' } ], - handler: resources.files.get.handler + handler: resources.get.handler } }) @@ -40,8 +40,8 @@ module.exports = (server) => { output: 'stream', maxBytes: Number.MAX_SAFE_INTEGER }, - handler: resources.files.add.handler, - validate: resources.files.add.validate + handler: resources.add.handler, + validate: resources.add.validate } }) diff --git a/src/http/gateway/resources/gateway.js b/src/http/gateway/resources/gateway.js index 4b6df5977f..4f6cc67b8c 100644 --- a/src/http/gateway/resources/gateway.js +++ b/src/http/gateway/resources/gateway.js @@ -94,7 +94,7 @@ module.exports = { return handleGatewayResolverError(err) } - const stream = ipfs.files.catReadableStream(data.multihash) + const stream = ipfs.catReadableStream(data.multihash) stream.once('error', (err) => { if (err) { log.error(err)