This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: send blobs when running ipfs-http-client in the browser #3184
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e4a1684
fix: normalise add input to blob in the browser
achingbrain efc443b
chore: add missing dep
achingbrain 541b6c2
chore: split content normalisation out
achingbrain 0d6fdb5
chore: fix up tests
achingbrain 95b6b8b
fix: turn blob to iterator in test
achingbrain 5f91a2e
chore: fix http tests
achingbrain 634400b
chore: only normalise to blob in the http client
achingbrain 9ae9e77
chore: fix up tests
achingbrain 8352346
chore: add test for passing metadata in field name to go-ipfs
achingbrain 4407e45
chore: remove redundant buffer check
achingbrain 044e275
chore: rename isbloby to isblob
achingbrain 9a6d98b
chore: rename isbloby to isblob
achingbrain d0e04db
chore: convert normalise input to just yield from the function
achingbrain 078bd4a
chore: add tests around browser readable streams of things
achingbrain b8a869c
chore: adds tests for more input types
achingbrain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
packages/ipfs-core-utils/src/files/normalise-input/index.browser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict' | ||
|
||
const normaliseContent = require('./normalise-content.browser') | ||
const normaliseInput = require('./normalise-input') | ||
|
||
/* | ||
* Transform one of: | ||
* | ||
* ``` | ||
* Bytes (Buffer|ArrayBuffer|TypedArray) [single file] | ||
* Bloby (Blob|File) [single file] | ||
* String [single file] | ||
* { path, content: Bytes } [single file] | ||
* { path, content: Bloby } [single file] | ||
* { path, content: String } [single file] | ||
* { path, content: Iterable<Number> } [single file] | ||
* { path, content: Iterable<Bytes> } [single file] | ||
* { path, content: AsyncIterable<Bytes> } [single file] | ||
* Iterable<Number> [single file] | ||
* Iterable<Bytes> [single file] | ||
* Iterable<Bloby> [multiple files] | ||
* Iterable<String> [multiple files] | ||
* Iterable<{ path, content: Bytes }> [multiple files] | ||
* Iterable<{ path, content: Bloby }> [multiple files] | ||
* Iterable<{ path, content: String }> [multiple files] | ||
* Iterable<{ path, content: Iterable<Number> }> [multiple files] | ||
* Iterable<{ path, content: Iterable<Bytes> }> [multiple files] | ||
* Iterable<{ path, content: AsyncIterable<Bytes> }> [multiple files] | ||
* AsyncIterable<Bytes> [single file] | ||
* AsyncIterable<Bloby> [multiple files] | ||
* AsyncIterable<String> [multiple files] | ||
* AsyncIterable<{ path, content: Bytes }> [multiple files] | ||
* AsyncIterable<{ path, content: Bloby }> [multiple files] | ||
* AsyncIterable<{ path, content: String }> [multiple files] | ||
* AsyncIterable<{ path, content: Iterable<Number> }> [multiple files] | ||
* AsyncIterable<{ path, content: Iterable<Bytes> }> [multiple files] | ||
* AsyncIterable<{ path, content: AsyncIterable<Bytes> }> [multiple files] | ||
* ``` | ||
* | ||
* Into: | ||
* | ||
* ``` | ||
* AsyncIterable<{ path, mode, mtime, content: Blob }> | ||
* ``` | ||
* | ||
* @param input Object | ||
* @return AsyncInterable<{ path, content: Blob }> | ||
*/ | ||
module.exports = (input) => normaliseInput(input, normaliseContent) |
49 changes: 49 additions & 0 deletions
49
packages/ipfs-core-utils/src/files/normalise-input/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict' | ||
|
||
const normaliseContent = require('./normalise-content') | ||
const normaliseInput = require('./normalise-input') | ||
|
||
/* | ||
* Transform one of: | ||
* | ||
* ``` | ||
* Bytes (Buffer|ArrayBuffer|TypedArray) [single file] | ||
* Bloby (Blob|File) [single file] | ||
* String [single file] | ||
* { path, content: Bytes } [single file] | ||
* { path, content: Bloby } [single file] | ||
* { path, content: String } [single file] | ||
* { path, content: Iterable<Number> } [single file] | ||
* { path, content: Iterable<Bytes> } [single file] | ||
* { path, content: AsyncIterable<Bytes> } [single file] | ||
* Iterable<Number> [single file] | ||
* Iterable<Bytes> [single file] | ||
* Iterable<Bloby> [multiple files] | ||
* Iterable<String> [multiple files] | ||
* Iterable<{ path, content: Bytes }> [multiple files] | ||
* Iterable<{ path, content: Bloby }> [multiple files] | ||
* Iterable<{ path, content: String }> [multiple files] | ||
* Iterable<{ path, content: Iterable<Number> }> [multiple files] | ||
* Iterable<{ path, content: Iterable<Bytes> }> [multiple files] | ||
* Iterable<{ path, content: AsyncIterable<Bytes> }> [multiple files] | ||
* AsyncIterable<Bytes> [single file] | ||
* AsyncIterable<Bloby> [multiple files] | ||
* AsyncIterable<String> [multiple files] | ||
* AsyncIterable<{ path, content: Bytes }> [multiple files] | ||
* AsyncIterable<{ path, content: Bloby }> [multiple files] | ||
* AsyncIterable<{ path, content: String }> [multiple files] | ||
* AsyncIterable<{ path, content: Iterable<Number> }> [multiple files] | ||
* AsyncIterable<{ path, content: Iterable<Bytes> }> [multiple files] | ||
* AsyncIterable<{ path, content: AsyncIterable<Bytes> }> [multiple files] | ||
* ``` | ||
* | ||
* Into: | ||
* | ||
* ``` | ||
* AsyncIterable<{ path, mode, mtime, content: AsyncIterable<Buffer> }> | ||
* ``` | ||
* | ||
* @param input Object | ||
* @return AsyncInterable<{ path, content: AsyncIterable<Buffer> }> | ||
*/ | ||
module.exports = (input) => normaliseInput(input, normaliseContent) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return type annotation is misleading. In browser context return type is
AsyncInterable<{ path:string, content:Blob }>
it would be nice to reflect that in a comment or change annotation to:That would mean that return type implements both
Blob
&AsyncIterable<Buffer>
interface which is still not true but it is better and makes tools like vscode able to assist you. If you do want to be true this would beBut that degrades inference because
content
ends up beingAsyncIterable<Buffer>|Blob
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module doesn't convert content to
Blob
, only toAsyncIterable<Buffer>
.index.browser.js
converts toBlob
.