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

Make add_bytes() work with raw blocks #334

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

Conversation

ProximaNova
Copy link

@ProximaNova ProximaNova commented Mar 7, 2025

It would be nice if add_bytes() had some more functionality. This pull request (PR) adds a bit more functionality to it. This adds function add_raw_bytes() which is basically add_bytes() except with this call to the HTTP/RPC API: return self._client.request('/add?cid-version=1&chunker=size-1048576',

It is worth explaining similar pull requests or issues here. Both of the following are more ambitious ideas which are like making parts of the code a Swiss Army Knife (for it to do many more things instead of the one/few things it currently does):

#288 titled "add_str() and add() do not take the same optional parameters". Ideally, add(), add_str(), and add_bytes() would all have the maximum amount of optional arguments, or at least each one would be able to add raw blocks. #288 is a short thread.

#287 titled "add optional arguments to add_str()" (long/longer thread). https://github.com/ipfs-shipyard/py-ipfs-http-client/pull/287/files looks great (I guess, didn't run personally that code)! Why was it not accepted!? @ntninja said "we'll probably complete this eventually." - that didn't happen. @ftyers seemed to have gotten embarrassed and was shy and therefore closed the PR, so that kinda killed enthusiasm for it.

My motivation for writing this is partly this issue -- oduwsdl/ipwb#853 -- however, I do think this is generally beneficial. The code I request to be merged here is solid and it does work. It is simple and adds a bit more useful functionality, so I think it would pass automated tests. add() can add raw blocks, but why shouldn't add_bytes() also be able to do that? I think they're used in different contexts, like add() only works on file objects and add_bytes() only works on streams/stdin/pipe (non-file things).

Edit 1: "minor" fixes. Edit 2: same.

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.

1 participant