ferristseng / rust-ipfs-api

IPFS HTTP client in Rust
Apache License 2.0
247 stars 68 forks source link

What's the equivalent of `ipfs object put <data>`? #76

Closed nathan-at-least closed 2 years ago

nathan-at-least commented 3 years ago

After reading over the API docs, I can't find a way to insert objects (the equivalent of ipfs_api::response::ObjectGetResponse.

Is the equivalent of the command line ipfs object put <data> present in the API?

If not, is this simply a gap or is there a different way to use the API to achieve this? I have not been able to use IpfsClient::object_new successfully at all, see #77 .

If there's a different way, I request updating the API docs to spell that out (maybe linking to it from IpfsClient::object_get ).

SionoiS commented 3 years ago

You could use DAG API it's intended to replace Object API anyway.

nathan-at-least commented 3 years ago

If the Object API is deprecated, why not remove the whole thing? If it's supported, why not support the whole API?

Or, keeping the same middle ground of mixed support, it may be good to add a note that the API will be deprecated and point devs to the DAG API. For a someone like me who's familiar with rust but just learning IPFS, these prompts could really help.

Ok, looking into the DAG api, I am unclear on how to publish two nodes linked together. Maybe an example could show how to do this? The only example shows posting a single node which does not link to any other CIDs. A really nice example for my purposes might use serde on some rust structs.

SionoiS commented 3 years ago

If the Object API is deprecated, why not remove the whole thing? If it's supported, why not support the whole API?

I guess nobody used the Object API so we didn't know it was broken :P

Or, keeping the same middle ground of mixed support, it may be good to add a note that the API will be deprecated and point devs to the DAG API. For a someone like me who's familiar with rust but just learning IPFS, these prompts could really help.

It's in the DAG API docs https://docs.ipfs.io/reference/cli/#ipfs-dag

Ok, looking into the DAG api, I am unclear on how to publish two nodes linked together. Maybe an example could show how to do this? The only example shows posting a single node which does not link to any other CIDs. A really nice example for my purposes might use serde on some rust structs.

A nice API to do that would be cool but I far as i know there's none in rust.

You can check my project for examples https://github.com/SionoiS/dit/blob/develop/linked-data/src/video.rs