Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

WIP Files #8

Closed
wants to merge 1 commit into from
Closed
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
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,85 @@ test.all(common)

A valid (read: that follows this interface) IPFS core implementation, must expose the following API.

## Group Files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "Group Files" a canonical api section name? I haven't seen this referred to anywhere -- could you link me?

Copy link
Contributor Author

@nginnever nginnever May 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Group is used it seems for the top level commands in the apiary, and group files is already taken from the mfs group, nomenclature ftw! we should talk more on what we call commands in ipfs in general.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just an apiary thing, or does putting the word "group" in front of everything add extra value to the reader?


### `Add`

> Store a Unixfs file or directory of files .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we either explain what "unixfs" means or link to a document that does?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unixfs is all lowercase


##### `Go` **WIP**

##### `JavaScript` - ipfs.add(path, [options, callback])

`path` The path to a file to be added to IPFS. Can be of type:
Copy link
Contributor

@hackergrrl hackergrrl May 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "toAdd" is a better name than "path", since it can take on many values; many of which are not paths. also not all types are files either, so maybe s/file/data?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even call it files

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even files is kind of misleading, since a stream !== a file. heck, maybe even something as nebulous as data. the real problem here is that this api call is becoming a kitchen sink; it becomes hard to define concrete terminology when you accept so many different things in one place.


- Callback, If no first argument is supplied a callback will return a duplex stream.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the semantics of this duplex stream?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Callback/function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"If no first argument is supplied" or "if a function is supplied"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. If no callback is passed, then a object duplex stream is returned.

- Path, String format path to a file to be added to IPFS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"string, in the form of a filesystem path to a file to be added"

- Stream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what kind? readable? writeable? transform? duplex?

Copy link
Contributor Author

@nginnever nginnever May 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readable, ty! unless duplex works too, pipe data to the through fixed sized chunker https://github.com/ipfs/js-ipfs-unixfs-engine/blob/master/src/importer.js#L67

- Object, with format `{ path: </foo/bar>, stream: <readable stream> }`
- Array, an [array] of objects with the above format.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is also the option that no 1st arg is passed, a duplex stream is returned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh good, added

`options` is a optional argument of type object, that can contain the following properties:

- `Recursive`. Add directory paths recursively.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do s/Recursive/recursive? it's js idiom to use camelcase names


`callback` must follow `function (err, object) {}` signature, where `err` is an error if the operation was not successful and `object` is an ndjson return with properties { Name (string), Hash (multihash) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "an ndjson return"?


If no `callback` is passed, a promise is returned.





### `Cat`

> Displays the data contained by an IPFS object(s) at the given path..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it "display" an object's data or does it retrieve it? Maybe "streams an IPFS object's data, given an IPFS multihash"?

Copy link
Contributor Author

@nginnever nginnever May 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to go-ipfs ipfs cat --help it "displays" the data but this should probably be specific to cli, i think streams the data makes more sense for a core spec


##### `Go` **WIP**

##### `JavaScript` - ipfs.cat(multihash, [callback])

`multihash` is a [multihash]() which can be passed as:
Copy link
Contributor

@hackergrrl hackergrrl May 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/[multihash]()/[multihash][] so we can take advantage of markdown footnotes (I added one for multihash in a recent PR)

grammar nit: no colon needed here


- Buffer, the raw Buffer of the multihash (or of and encoded version)
- String, the toString version of the multihash (or of an encoded version)

`callback` must follow `function (err, stream) {}` signature, where `err` is an error if the operation was not successful and `stream` is a readable stream.

If no `callback` is passed, a promise is returned.





### `Get`

> Download IPFS UnixFS files and directories with tar archiving and gzip compression options.

##### `Go` **WIP**

##### `JavaScript` - ipfs.get(multihash, [options, callback])

`multihash` is a [multihash]() which can be passed as:

- Buffer, the raw Buffer of the multihash (or of and encoded version)
- String, the toString version of the multihash (or of an encoded version)

`options` is a optional argument of type object, that can contain the following properties:

- `output`, string - The path where output should be stored.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"... on the local file system"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the semantics if this is vs is not set? If set, does this give us the below duplex stream and write to the local fs? If not set, does it not write?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No output string creates files on the cwd for the cli. Not sure how this will be handled exactly yet if provided to the http-api, but that is a different spec and this probably belongs there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems a bit confusing. good layering would be to have the core just provide plain streams to the caller (idempotent; doesn't mutate global fs), and let downstream (e.g. cli) implement things like fs writes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, think i was trying to add documentation from what the cli/http server would handle the streams. Core will simply be streams.

- `archive`, bool - Output a TAR archive.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for each file? for the entire file+directory structure?

Copy link
Contributor Author

@nginnever nginnever May 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have not figured that one out yet :D

- `compress`, bool - Compress the output with GZIP compression.
- `compression-level` int - The level of compression (1-9).

`callback` must follow `function (err, ee) {}` signature, where `err` is an error if the operation was not successful and `ee` is an event emitter containing an object of {stream, path, dir} where dir is a boolean flag for a directory path. [ee](https://github.com/ipfs/js-ipfs-unixfs-engine/blob/master/src/exporter.js) // This should be upgraded to duplex object stream.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are moving and defining the spec. Let's move the 'exporter' to become a duplex stream instead of an event emitter, otherwise it will be a lil strange why one is EE and another is DuplexStream. This way we will be also able to leverage the streams properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for a duplex stream on get. This should be a readable stream

Copy link
Contributor Author

@nginnever nginnever May 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as the stream can stay an object stream for getting paths back,

https://github.com/ipfs/js-ipfs-unixfs-engine/blob/master/src/exporter.js#L55


If no `callback` is passed, a promise is returned.





## Object

### `object.new`
Expand Down