Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: update HTTP API and Gateway to use latest Files API
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Oct 26, 2018
1 parent 4c88152 commit d874314
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/http/api/resources/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/http/api/routes/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})

Expand All @@ -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
}
})

Expand All @@ -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
}
})

Expand Down
2 changes: 1 addition & 1 deletion src/http/gateway/resources/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d874314

Please sign in to comment.