Skip to content
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

Add 3 remote pin api #102

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Add 3 remote pin api #102

wants to merge 9 commits into from

Conversation

zu1k
Copy link

@zu1k zu1k commented Jun 11, 2022

Add 3 remote pin api:

  • /pin/remote/add
  • /pin/remote/ls
  • /pin/remote/rm

zu1k added 7 commits June 11, 2022 21:12
Signed-off-by: zu1k <i@zu1k.com>
Signed-off-by: zu1k <i@zu1k.com>
Signed-off-by: zu1k <i@zu1k.com>
Signed-off-by: zu1k <i@zu1k.com>
Signed-off-by: zu1k <i@zu1k.com>
Signed-off-by: zu1k <i@zu1k.com>
Signed-off-by: zu1k <i@zu1k.com>
@zu1k zu1k marked this pull request as draft June 12, 2022 03:03
Signed-off-by: zu1k <i@zu1k.com>
@ferristseng ferristseng marked this pull request as ready for review July 26, 2022 13:02
@ferristseng
Copy link
Owner

@zu1k Do you want me to review this?

@zu1k
Copy link
Author

zu1k commented Jul 30, 2022

@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
Copy link
Author

zu1k commented Jul 30, 2022

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":""}

ipfs-api-prelude/src/api.rs Show resolved Hide resolved
ipfs-api-prelude/src/api.rs Show resolved Hide resolved
ipfs-api-prelude/src/api.rs Outdated Show resolved Hide resolved
ipfs-api-prelude/src/api.rs Show resolved Hide resolved
ipfs-api-prelude/src/request/pin.rs Outdated Show resolved Hide resolved
ipfs-api-prelude/src/request/pin.rs Outdated Show resolved Hide resolved
@ferristseng
Copy link
Owner

@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.

Signed-off-by: zu1k <i@zu1k.com>
@zu1k
Copy link
Author

zu1k commented Jul 31, 2022

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
Copy link
Contributor

Xuanwo commented Jul 31, 2022

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.

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

Successfully merging this pull request may close these issues.

3 participants