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

fix: file support when added as object #2105

Merged
merged 3 commits into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"execa": "^1.0.0",
"form-data": "^2.3.3",
"hat": "0.0.3",
"interface-ipfs-core": "~0.103.0",
"interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#fix/file-support",
"ipfsd-ctl": "~0.42.0",
"libp2p-websocket-star": "~0.10.2",
"ncp": "^2.0.0",
Expand Down
8 changes: 6 additions & 2 deletions src/core/components/files-regular/add-pull-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,16 @@ function normalizeContent (content, opts) {
}

if (data && data.content && typeof data.content !== 'function') {
if (supportsFileReader && kindOf(data.content) === 'file') {
data = { path: data.path, content: toPull.source(streamFromFileReader(data.content)) }
}

if (Buffer.isBuffer(data.content)) {
data.content = pullValues([data.content])
data = { path: data.path, content: pullValues([data.content]) }
}

if (isStream.readable(data.content)) {
data.content = toPull.source(data.content)
data = { path: data.path, content: toPull.source(data.content) }
}
}

Expand Down