Skip to content

support for --hash and --raw-leaves arguments #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brenzi opened this issue Jan 30, 2019 · 5 comments
Closed

support for --hash and --raw-leaves arguments #26

brenzi opened this issue Jan 30, 2019 · 5 comments

Comments

@brenzi
Copy link

brenzi commented Jan 30, 2019

I've successfully used your examples, but what I'd like to do is the equivalent to

> echo awesome test content > test.txt
> ipfs add --raw-leaves test.txt
zb2rhgCbaGmTcdZVRpZi3Z8CsdtAbFv7PRdRD9s6mKtef6LK9
> ipfs add --hash blake2b-256 test.txt
zCT5htke82ziqES2sZUP6MPR1EcC3DchZjbFuGeQcTfm16m5q5e8

Is that supported? I couldn't find anything in the docs.

@sameer
Copy link
Contributor

sameer commented Jan 30, 2019

Glad you got it working!
The way it is currently written, it is not supported -- the spec for the Add request does not have any of the current parameters, so the api add function can't enable these.

There are several requests that need additional parameters like your use case, but most users would not need them. This might require adding a method like add_with_raw_leaves or even rewriting the api to be builder-style.

@brenzi
Copy link
Author

brenzi commented Jan 30, 2019

The API actually supports it:

> curl --form "[email protected]" http://127.0.0.1:5001/api/v0/add?raw-leaves=True
{"Name":"test.txt","Hash":"zb2rhgCbaGmTcdZVRpZi3Z8CsdtAbFv7PRdRD9s6mKtef6LK9","Size":"21"}

So, the quick and dirty way would be your first suggestion, just add a new request type add_with_raw_leaves, add_with_hash_blake2b_256

I don't think that would be sustainable. What about extending the trait ApiRequest with optional arguments?

@ferristseng
Copy link
Owner

I think we could support this. There are already some ApiRequest implementations that have optional arguments. Maybe we could have an add_with_options that takes in an AddRequest that's populated with the optional arguments?

@sameer
Copy link
Contributor

sameer commented Jan 30, 2019

The API actually supports it:

I agree, I was referring to this implementation of it -- sorry for the confusion.

An add with options sounds like a good idea. The add request struct could implement default and the add function could just wrap the with options variant.

@sameer
Copy link
Contributor

sameer commented Feb 8, 2019

The go IPFS API implementation of add uses functions that modify the request itself, and offers a few that are standard. Would that be something better to do here, since the api is technically v0?

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

No branches or pull requests

3 participants