Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
-------
dict
+------+----------------------------------+
| Hash | Hash of the newly derived object |
+------+----------------------------------+
"""
args = (root,)
body, headers = multipart.stream_files(data, self.chunk_size)
return self._client.request('/object/patch/set-data', args, decoder='json', data=body,
headers=headers, **kwargs)
class Section(base.SectionBase):
patch = base.SectionProperty(PatchSection)
def data(self, cid, **kwargs):
r"""Returns the raw bytes in an IPFS object.
.. code-block:: python
>>> client.object.data('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D')
b'\x08\x01'
Parameters
----------
cid : Union[str, cid.CIDv0, cid.CIDv1]
Key of the object to retrieve, in CID format
Returns
{'Ref': 'QmSY8RfVntt3VdxWppv9w5hWgNrE31uctgTi ā¦ eXJY', 'Err': ''}]
Returns
-------
list
"""
return self._client.request('/refs/local', decoder='json', **kwargs)
class Section(base.SectionBase):
"""
Features that are subject to change and are only provided for convinience
"""
log = base.SectionProperty(LogSection)
refs = base.SectionProperty(RefsSection)
Multiaddr filter to remove
Returns
-------
dict
+---------+-------------------------------+
| Strings | List of swarm filters removed |
+---------+-------------------------------+
"""
args = (address,) + addresses
return self._client.request('/swarm/filters/rm', args, decoder='json', **kwargs)
class Section(base.SectionBase):
filters = base.SectionProperty(FiltersSection)
@base.returns_single_item
def addrs(self, **kwargs):
"""Returns the addresses of currently connected peers by peer id.
.. code-block:: python
>>> pprint(client.swarm.addrs())
{'Addrs': {
'QmNMVHJTSZHTWMWBbmBrQgkA1hZPWYuVJx2DpSGESWW6Kn': [
'/ip4/10.1.0.1/tcp/4001',
'/ip4/127.0.0.1/tcp/4001',
'/ip4/51.254.25.16/tcp/4001',
'/ip6/2001:41d0:b:587:3cae:6eff:fe40:94d8/tcp/4001',
'/ip6/2001:470:7812:1045::1/tcp/4001',
Truncate the file to size zero before writing
count : int
Maximum number of bytes to read from the source ``file``
"""
opts = {"offset": offset, "create": create, "truncate": truncate}
if count is not None:
opts["count"] = count
kwargs.setdefault("opts", {}).update(opts)
args = (path,)
body, headers = multipart.stream_files(file, self.chunk_size)
return self._client.request('/files/write', args, data=body, headers=headers, **kwargs)
class Base(base.ClientBase):
files = base.SectionProperty(Section)
def add(self, file, *files, **kwargs):
"""Add a file, or directory of files to IPFS.
.. code-block:: python
>>> with io.open('nurseryrhyme.txt', 'w', encoding='utf-8') as f:
... numbytes = f.write('Mary had a little lamb')
>>> client.add('nurseryrhyme.txt')
{'Hash': 'QmZfF6C9j4VtoCsTp4KSrhYH47QMd3DNXVZBKaxJdhaPab',
'Name': 'nurseryrhyme.txt'}
Parameters
----------
file : Union[str, bytes, os.PathLike, int, io.IOBase]
ā¦
{'Ref': 'QmSY8RfVntt3VdxWppv9w5hWgNrE31uctgTi ā¦ eXJY', 'Err': ''}]
Returns
-------
list
"""
return self._client.request('/refs/local', decoder='json', **kwargs)
class Section(base.SectionBase):
"""
Features that are subject to change and are only provided for convinience
"""
log = base.SectionProperty(LogSection)
refs = base.SectionProperty(RefsSection)