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

Added more documentation #13

Closed
wants to merge 37 commits into from
Closed

Added more documentation #13

wants to merge 37 commits into from

Conversation

RichardLitt
Copy link
Contributor

So far:

  • add

+ chunker (boolean, optional) - chunking algorithm to use
+ pin (boolean, optional) - Pin this object when adding. Default true

+ Response 200 (text/plain)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was unable to get "http://127.0.0.1:5001/api/v0/add?arg=/Users/richard/test" to work on Postman, so I honestly am not sure if this is the right response of not. It's what I get in the CLI, though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Path to a file will not work from http api, you have to send the file content via multipart if you want to add something via http

Copy link

Choose a reason for hiding this comment

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

If you need to test adds in Postman, you can use the form-data body Content-Type, set a non-empty value for the key, and select 'File' instead of 'Text'.

In curl, you can do:

curl -F "file=@/some/file/path" http://localhost:5001/api/v0/add

Copy link

Choose a reason for hiding this comment

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

BTW, could be cool to show curl commands for all these methods, does apiary have any good places where we could put that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no option to select File instead of Text if I am using a GET command. If I use a PUT or a POST, there is, but I just get a 403 - Forbidden back. Ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could include the curl command directly in the description, like this. I like it! What do you think? cc @dignifiedquire

# Group add [GET /add{?arg}{&recursive,quiet,silent,progress,trickle,only%2Dhash,wrap%2Dwith%2Ddirectory,hidden,chunker,pin}]
Add an object to ipfs.

Adds contents of <path> to ipfs. Use -r to add directories.
Note that directories are added recursively, to form the ipfs
MerkleDAG. A smarter partial add with a staging area (like git)
remains to be implemented.

#### curl

    curl -F "file=@test/" -r http://localhost:5001/api/v0/add

+ Parameters
    + arg (string, required) - The path to a file to be added to IPFS
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like this:
screenshot 2015-12-25 20 50 09

Copy link
Contributor

Choose a reason for hiding this comment

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

from @RichardLitt: There's no option to select File instead of Text if I am using a GET command. If I use a PUT or a POST, there is, but I just get a 403 - Forbidden back. Ideas?

That would be because no one (i.e Apiary) is expecting for a file to be sent in a GET request and all the other methods are blocked by CORS, if the headers are not set.

This one, in particular, is not great, but this should be a good start. There's a few things in the `ipfs object` docs that are inconsistent; for instance, I'm not sure that <name>  and <ref> aren't options. The "--encoding" flag is mentioned several times, but never specified as an option, unless it is in `put`, where it has the name `inputenc`, which I think does something different. The formatting is also a bit inconsistent - tick marks given here but not there, and so on. I think I'll need to comb over this in more detail later. For now, here's a stub. Better to have something than nothing.
It seems strange to me that pin/rm has the same 200 response as pin/add. But that seems to be the case.
I got a malformed syntax error when trying refs on Postman, but it seemed to work fine in the command line. I am not sure what exactly is happening with the format option, and I suspect that coud be improved a bit. Otherwise, this seems fine to me. Threw in headers because I might as well, they were right there.
I didn't get a response in my terminal for tarcat, so I assume there is none. I was unable to get tar/add to work, as well, in Postman, but in the terminal it returned the hash of the file, so that is probably what it returns there, too.
@RichardLitt
Copy link
Contributor Author

Ok, I've finished going through all of the commands for the first time. Now is the harder bit; which is, namely, figuring out why some don't work in the API at all, where the inconsistencies are in the documentation, and how to clean up and make this, as a whole, better. For now, though, I think this is a massive step forward. Can someone give a brief overview of my work here, point out any glaring issues?

@RichardLitt
Copy link
Contributor Author

This, of course, relates and possibly closes #7.


<link base58 hash>

Note: list all refs recursively with -r.
Copy link
Collaborator

Choose a reason for hiding this comment

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

cli notation

This is not the result I got back from Postman, as I wasn't able to make it work there. Here is the curl response.
@RichardLitt
Copy link
Contributor Author

@dignifiedquire Want to take another pass?

@RichardLitt RichardLitt mentioned this pull request Dec 27, 2015
@RichardLitt
Copy link
Contributor Author

Removed 'needs review' pending current changes ongoing after the API talk.

@RichardLitt
Copy link
Contributor Author

Please do not close or delete this branch. I am using it to stub out future PRs. This PR will not and should not be merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants