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

fix: send blobs when running ipfs-http-client in the browser #3184

Merged
merged 15 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 18 additions & 6 deletions docs/core-api/FILES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ _Explore the Mutable File System through interactive coding challenges in our [P
- [The Regular API](#the-regular-api)
- [`ipfs.add(data, [options])`](#ipfsadddata-options)
- [Parameters](#parameters)
- [FileStream](#filestream)
- [FileObject](#fileobject)
- [FileContent](#filecontent)
- [Options](#options)
- [Returns](#returns)
- [`ipfs.addAll(source, [options])`](#ipfsaddallsource-options)
Expand Down Expand Up @@ -108,12 +111,19 @@ The regular, top-level API for add, cat, get and ls Files on IPFS

`data` may be:

* `Blob`
* `String`
* `Uint8Array`
* `FileContent` (see below for definition)
* `FileObject` (see below for definition)
* `Iterable<Uint8Array>`
* `AsyncIterable<Uint8Array>`
* `FileStream<FileContent>` (see below for definition)

##### FileStream

`FileStream` is a stream of `FileContent` or `FileObject` entries of the type:

```js
Iterable<FileContent|FileObject> | AsyncIterable<FileContent|FileObject> | ReadableStream<FileContent|FileObject>
```

##### FileObject

`FileObject` is a plain JS object of the following form:

Expand All @@ -136,10 +146,12 @@ If no `content` is passed, then the item is treated as an empty directory.

One of `path` or `content` _must_ be passed.

##### FileContent

`FileContent` is one of the following types:

```js
Uint8Array | Blob | String | Iterable<Uint8Array> | AsyncIterable<Uint8Array>
Uint8Array | Blob | String | Iterable<Uint8Array | Number> | AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>
```

`UnixTime` is one of the following types:
Expand Down
10 changes: 7 additions & 3 deletions packages/ipfs-core-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@
},
"license": "MIT",
"dependencies": {
"blob-to-it": "0.0.1",
"browser-readablestream-to-it": "0.0.1",
"buffer": "^5.6.0",
"cids": "^0.8.3",
"err-code": "^2.0.0",
"ipfs-utils": "^2.2.2"
"ipfs-utils": "^2.2.2",
"it-all": "^1.0.1",
"it-map": "^1.0.0",
"it-peekable": "0.0.1"
},
"devDependencies": {
"aegir": "^23.0.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"delay": "^4.3.0",
"dirty-chai": "^2.0.1",
"it-all": "^1.0.1"
"dirty-chai": "^2.0.1"
}
}
298 changes: 0 additions & 298 deletions packages/ipfs-core-utils/src/files/normalise-input.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const normaliseContent = require('./normalise-content.browser')
const normaliseInput = require('./normalise-input')

/*
* Transforms any of the `ipfs.add` input types into
*
* ```
* AsyncIterable<{ path, mode, mtime, content: Blob }>
* ```
*
* See https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/FILES.md#ipfsadddata-options
*
* @param input Object
* @return AsyncInterable<{ path, mode, mtime, content: Blob }>
*/
module.exports = (input) => normaliseInput(input, normaliseContent)
Loading