Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
offset : int
Byte offset at which to begin writing at
create : bool
Create the file if it does not exist
truncate : bool
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", opts)
args = (path,)
body, headers = multipart.stream_files(file, self.chunk_size)
return self._client.request('/files/write', args,
data=body, headers=headers, **kwargs)
----------
cid : Union[str, cid.CIDv0, cid.CIDv1]
The hash of an ipfs object to modify
new_data : Union[str, bytes, os.PathLike, io.IOBase, int]
The data to append to the object's data section
Returns
-------
dict
+------+----------------------------------+
| Hash | Hash of the newly derived object |
+------+----------------------------------+
"""
args = (str(cid),)
body, headers = multipart.stream_files(new_data, self.chunk_size)
return self._client.request('/object/patch/append-data', args, decoder='json',
data=body, headers=headers, **kwargs)
{'Key': 'QmeV6C6XVt1wf7V7as7Yak3mxPma8jzpqyhtRtCvpKcfBb',
'Size': 22}
Parameters
----------
file : Union[str, bytes, os.PathLike, io.IOBase, int]
The data to be stored as an IPFS block
Returns
-------
dict
Information about the new block
See :meth:`~ipfshttpclient.Client.block.stat`
"""
body, headers = multipart.stream_files(file, self.chunk_size)
return self._client.request('/block/put', decoder='json', data=body,
headers=headers, **kwargs)
offset : int
Byte offset at which to begin writing at
create : bool
Create the file if it does not exist
truncate : bool
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)
}
Parameters
----------
file : Union[str, bytes, os.PathLike, io.IOBase, int]
(JSON) object from which the DAG object will be created
Returns
-------
dict
Hash and links of the created DAG object
See the :meth:`~ipfshttpclient.Client.object.links` method for
details.
"""
body, headers = multipart.stream_files(file, self.chunk_size)
return self._client.request('/object/put', decoder='json', data=body,
headers=headers, **kwargs)
>>> c.block_put(io.BytesIO(b'Mary had a little lamb'))
{'Key': 'QmeV6C6XVt1wf7V7as7Yak3mxPma8jzpqyhtRtCvpKcfBb',
'Size': 22}
Parameters
----------
file : io.RawIOBase
The data to be stored as an IPFS block
Returns
-------
dict : Information about the new block
See :meth:`~ipfshttpclient.Client.block_stat`
"""
body, headers = multipart.stream_files(file, self.chunk_size)
return self._client.request('/block/put', decoder='json',
data=body, headers=headers, **kwargs)
'Size': 8, 'Name': 'some link'}
]
}
Parameters
----------
file : io.RawIOBase
(JSON) object from which the DAG object will be created
Returns
-------
dict : Hash and links of the created DAG object
See :meth:`~ipfshttpclient.Object.object_links`
"""
body, headers = multipart.stream_files(file, self.chunk_size)
return self._client.request('/object/put', decoder='json',
data=body, headers=headers, **kwargs)
----------
root : str
IPFS hash of the object to modify
data : Union[str, bytes, os.PathLike, io.IOBase, int]
The new data to store in root
Returns
-------
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)
>>> c.object_patch_append_data("QmZZmY … fTqm", io.BytesIO(b"bla"))
{'Hash': 'QmR79zQQj2aDfnrNgczUhvf2qWapEfQ82YQRt3QjrbhSb2'}
Parameters
----------
multihash : str
The hash of an ipfs object to modify
new_data : io.RawIOBase
The data to append to the object's data section
Returns
-------
dict : Hash of new object
"""
args = (multihash,)
body, headers = multipart.stream_files(new_data, self.chunk_size)
return self._client.request('/object/patch/append-data', args,
decoder='json',
data=body, headers=headers, **kwargs)