Skip to content

Conversation

@Zer0C001
Copy link

@Zer0C001 Zer0C001 commented Dec 28, 2025

Allows for new usage:

from ipyfs.ipfs import IPFS
ipfs=IPFS(init_self_attr_RPCs=['add','pin','cat','ls'],response_return_status_code=False)
### now we can call ipfs.add instead of making a new Add object
### ... 
### ipfs add -r : 
result=ipfs.add(files={ str(Path(i[0],j)): (str(Path(i[0],j)) , open(Path(i[0],j),'br')) for i in Path(the_path).walk() for j in i[2]})
ls=ipfs.ls(result[-1]['Hash']) ## result is list, last element is the top directory

changes:

  • IPFS:
    • __init__: added arguments
      • response_return_status_code: passed to _response
      • init_self_attr_RPCs : add RPC objects as attributes to the IPFS object ( changed __init__ on multiple classes to allow for that )
    • _response:
      • argument response_return_status_code: if set to False return just result, since we raise an exception if response.status_code != 200 anyway
      • try to parse result as multiple json lines ( returned as list ), eg. when adding multiple files
    • _send : add argument files dict
  • Add : added arguments :
    • to_files: Add reference to Files API (MFS)
    • pin_name: Name to use for the pin
    • files: add multiple files
  • Pin: added arguments :
    • add:
      • name: An optional name for created pin
    • ls:
      • name: Limit returned pins to ones with names that contain the value provided (case-sensitive, partial match). Implies --names=true.
      • names: Include pin names in the output

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