How to use the ipfshttpclient.multipart.stream_files function in ipfshttpclient

To help you get started, we’ve selected a few ipfshttpclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs / py-ipfs-http-client / ipfshttpclient / client.py View on Github external
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)
github ipfs / py-ipfs-http-client / ipfshttpclient / client / object.py View on Github external
----------
		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)
github ipfs / py-ipfs-http-client / ipfshttpclient / client / block.py View on Github external
{'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)
github ipfs / py-ipfs-http-client / ipfshttpclient / client / files.py View on Github external
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)
github ipfs / py-ipfs-http-client / ipfshttpclient / client / object.py View on Github external
}

		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)
github ipfs / py-ipfs-http-client / ipfshttpclient / client.py View on Github external
>>> 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)
github ipfs / py-ipfs-http-client / ipfshttpclient / client.py View on Github external
'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)
github ipfs / py-ipfs-http-client / ipfshttpclient / client / object.py View on Github external
----------
		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)
github ipfs / py-ipfs-http-client / ipfshttpclient / client.py View on Github external
>>> 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)