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

Commit 17ec8ea

Browse files
committed
feat: update HTTP API and Gateway to use latest Files API
1 parent 7f6495d commit 17ec8ea

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/http/api/resources/files.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ exports.cat = {
7979
const options = request.pre.args.options
8080
const ipfs = request.server.app.ipfs
8181

82-
ipfs.files.cat(key, options, (err, stream) => {
82+
ipfs.cat(key, options, (err, stream) => {
8383
if (err) {
8484
log.error(err)
8585
if (err.message === 'No such file') {
86-
reply({Message: 'No such file', Code: 0, Type: 'error'}).code(500)
86+
reply({ Message: 'No such file', Code: 0, Type: 'error' }).code(500)
8787
} else {
88-
reply({Message: 'Failed to cat file: ' + err, Code: 0, Type: 'error'}).code(500)
88+
reply({ Message: 'Failed to cat file: ' + err, Code: 0, Type: 'error' }).code(500)
8989
}
9090
return
9191
}
@@ -113,7 +113,7 @@ exports.get = {
113113
const ipfs = request.server.app.ipfs
114114
const pack = tar.pack()
115115

116-
ipfs.files.get(cid, (err, filesArray) => {
116+
ipfs.get(cid, (err, filesArray) => {
117117
if (err) {
118118
log.error(err)
119119
pack.emit('error', err)
@@ -258,7 +258,7 @@ exports.add = {
258258

259259
pull(
260260
fileAdder,
261-
ipfs.files.addPullStream(options),
261+
ipfs.addPullStream(options),
262262
pull.map((file) => {
263263
return {
264264
Name: file.path, // addPullStream already turned this into a hash if it wanted to

src/http/api/routes/files.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ module.exports = (server) => {
1212
path: '/api/v0/cat',
1313
config: {
1414
pre: [
15-
{ method: resources.files.cat.parseArgs, assign: 'args' }
15+
{ method: resources.cat.parseArgs, assign: 'args' }
1616
],
17-
handler: resources.files.cat.handler
17+
handler: resources.cat.handler
1818
}
1919
})
2020

@@ -24,9 +24,9 @@ module.exports = (server) => {
2424
path: '/api/v0/get',
2525
config: {
2626
pre: [
27-
{ method: resources.files.get.parseArgs, assign: 'args' }
27+
{ method: resources.get.parseArgs, assign: 'args' }
2828
],
29-
handler: resources.files.get.handler
29+
handler: resources.get.handler
3030
}
3131
})
3232

@@ -40,8 +40,8 @@ module.exports = (server) => {
4040
output: 'stream',
4141
maxBytes: Number.MAX_SAFE_INTEGER
4242
},
43-
handler: resources.files.add.handler,
44-
validate: resources.files.add.validate
43+
handler: resources.add.handler,
44+
validate: resources.add.validate
4545
}
4646
})
4747

src/http/gateway/resources/gateway.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ module.exports = {
9494
return handleGatewayResolverError(err)
9595
}
9696

97-
const stream = ipfs.files.catReadableStream(data.multihash)
97+
const stream = ipfs.catReadableStream(data.multihash)
9898
stream.once('error', (err) => {
9999
if (err) {
100100
log.error(err)

0 commit comments

Comments
 (0)