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

Commit 4ba0a24

Browse files
author
Alan Shaw
authored
fix: block.put with non default options (#1600)
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
1 parent 2d7cfc5 commit 4ba0a24

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"expose-loader": "~0.7.5",
7272
"form-data": "^2.3.2",
7373
"hat": "0.0.3",
74-
"interface-ipfs-core": "~0.76.1",
74+
"interface-ipfs-core": "~0.78.0",
7575
"ipfsd-ctl": "~0.39.1",
7676
"mocha": "^5.2.0",
7777
"ncp": "^2.0.0",
@@ -111,7 +111,7 @@
111111
"ipfs-block": "~0.7.1",
112112
"ipfs-block-service": "~0.14.0",
113113
"ipfs-http-response": "~0.1.2",
114-
"ipfs-mfs": "~0.3.0",
114+
"ipfs-mfs": "~0.4.0",
115115
"ipfs-multipart": "~0.1.0",
116116
"ipfs-repo": "~0.24.0",
117117
"ipfs-unixfs": "~0.1.15",
@@ -147,7 +147,7 @@
147147
"mkdirp": "~0.5.1",
148148
"multiaddr": "^5.0.0",
149149
"multiaddr-to-uri": "^4.0.0",
150-
"multibase": "~0.4.0",
150+
"multibase": "~0.5.0",
151151
"multihashes": "~0.4.13",
152152
"once": "^1.4.0",
153153
"path-exists": "^3.0.0",

src/http/api/resources/block.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
const CID = require('cids')
44
const multipart = require('ipfs-multipart')
5-
const Block = require('ipfs-block')
6-
const waterfall = require('async/waterfall')
7-
const multihashing = require('multihashing-async')
85
const Buffer = require('safe-buffer').Buffer
96
const debug = require('debug')
107
const log = debug('jsipfs:http-api:block')
@@ -100,15 +97,11 @@ exports.put = {
10097
const data = request.pre.args.data
10198
const ipfs = request.server.app.ipfs
10299

103-
waterfall([
104-
(cb) => multihashing(data, 'sha2-256', (err, multihash) => {
105-
if (err) {
106-
return cb(err)
107-
}
108-
cb(null, new Block(data, new CID(multihash)))
109-
}),
110-
(block, cb) => ipfs.block.put(block, cb)
111-
], (err, block) => {
100+
ipfs.block.put(data, {
101+
mhtype: request.query.mhtype,
102+
format: request.query.format,
103+
version: request.query.version && parseInt(request.query.version)
104+
}, (err, block) => {
112105
if (err) {
113106
log.error(err)
114107
return reply({

test/utils/interface-common-factory.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
const each = require('async/each')
55
const IPFSFactory = require('ipfsd-ctl')
6+
const IpfsApi = require('ipfs-api')
67
const IPFS = require('../../src')
78

89
function createFactory (options) {
@@ -11,6 +12,10 @@ function createFactory (options) {
1112
options.factoryOptions = options.factoryOptions || { type: 'proc', exec: IPFS }
1213
options.spawnOptions = options.spawnOptions || { initOptions: { bits: 512 } }
1314

15+
if (options.factoryOptions.type !== 'proc') {
16+
options.factoryOptions.IpfsApi = options.factoryOptions.IpfsApi || IpfsApi
17+
}
18+
1419
const ipfsFactory = IPFSFactory.create(options.factoryOptions)
1520

1621
return function createCommon () {

0 commit comments

Comments
 (0)