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

Commit

Permalink
fix: file support when added as object (#2105)
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
  • Loading branch information
Alan Shaw authored May 24, 2019
1 parent 7815c2f commit ba80e40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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": "~0.104.0",
"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

0 comments on commit ba80e40

Please sign in to comment.