ferristseng / rust-ipfs-api

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

Add 3 remote pin api #102

Open zu1k opened 2 years ago

zu1k commented 2 years ago

Add 3 remote pin api:

ferristseng commented 2 years ago

@zu1k Do you want me to review this?

zu1k commented 2 years ago

@ferristseng Sorry for the delay.

This PR is currently available, but not complete.

I found that some api's actual implementation is slightly different from the description in the documentation, especially when dealing with multiple cids at the same time.

You can review this PR now and I'll add more details on the problem I'm having so far at a later time.

zu1k commented 2 years ago

The problem mainly lies in the processing of multiple cids. The document says to use comma to separate, but after testing, it is found that the document is inconsistent with the implementation.

comma-separated

as described in the documentation, but doesn't work

# curl -X POST "http://192.168.226.4:5001/api/v0/pin/remote/ls?service=Pinata&cid=bafybeiaq3hspbuvhvg7nlxjjvsnzit6m6hevrjwedoj4jbx6uycgkkexni%2CQmfWC6JwVxmjVQfPpSiTsxFaSBdPTtFCd1B4aqMqRgaeMU"
{"Message":"CID \"bafybeiaq3hspbuvhvg7nlxjjvsnzit6m6hevrjwedoj4jbx6uycgkkexni,QmfWC6JwVxmjVQfPpSiTsxFaSBdPTtFCd1B4aqMqRgaeMU\" cannot be parsed: illegal base32 data at input byte 58","Code":0,"Type":"error"}

multi params

It works, but it seems that Rust http client do not support this. Please let me know if there is a suitable way to implement this.

# curl -X POST "http://192.168.226.4:5001/api/v0/pin/remote/ls?service=Pinata&cid=bafybeiaq3hspbuvhvg7nlxjjvsnzit6m6hevrjwedoj4jbx6uycgkkexni&cid=QmfWC6JwVxmjVQfPpSiTsxFaSBdPTtFCd1B4aqMqRgaeMU"
{"Status":"pinned","Cid":"QmfWC6JwVxmjVQfPpSiTsxFaSBdPTtFCd1B4aqMqRgaeMU","Name":""}
{"Status":"pinned","Cid":"bafybeiaq3hspbuvhvg7nlxjjvsnzit6m6hevrjwedoj4jbx6uycgkkexni","Name":""}
ferristseng commented 2 years ago

@ferristseng Sorry for the delay.

This PR is currently available, but not complete.

I found that some api's actual implementation is slightly different from the description in the documentation, especially when dealing with multiple cids at the same time.

You can review this PR now and I'll add more details on the problem I'm having so far at a later time.

No rush! It just looked pretty complete so I wanted to check and see what was up.

zu1k commented 2 years ago

No rush! It just looked pretty complete so I wanted to check and see what was up.

I still haven't found a proper way to generate request parameters like cid=cid_1&cid=cid_2, please let me know if there is a proper way.

Maybe we can pull a request to kubo (go-ipfs) to support comma separation.

Xuanwo commented 2 years ago

There is not http standard supports query like cid=abc&cid=def. I think we should report this as a bug to kubo.

As in this PR, I prefer to merge as-is. We can start another issue to track the multiple cids support.