(self, file: utils.clean_file_t, *files: utils.clean_file_t,
	        recursive: bool = False,
	        pattern: multipart.match_spec_t[ty.AnyStr] = None,
	        trickle: bool = False, follow_symlinks: bool = False,
	        period_special: bool = True, only_hash: bool = False,
	        wrap_with_directory: bool = False, chunker: ty.Optional[str] = None,
	        pin: bool = True, raw_leaves: bool = None, nocopy: bool = False,
	        cid_version: ty.Optional[int] = None,
	        **kwargs: base.CommonArgs)
return [base.ResponseBase(v) for v in resp]
Adds a file, several files or directory of files to IPFS
		
		Arguments marked as “directories only” will be ignored unless *file*
		refers to a directory path or file descriptor. Passing a directory file
		descriptor is currently restricted to Unix (due to Python standard
		library limitations on Windows) and will prevent the *nocopy* feature
		from working.
		
		.. 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'}
		
		Directory uploads
		-----------------
		
		By default only regular files and directories immediately below the given
		directory path/FD are uploaded to the connected IPFS node; to upload an
		entire directory tree instead, *recursive* can be set to ``True``.
		Symbolic links and special files (pipes, sockets, devices nodes, …) cannot
		be represented by the UnixFS data structure this call creates and hence
		are ignored while scanning the target directory, to include the targets
		of symbolic links in the upload set *follow_symlinks* to ``True``.
		
		The set of files and directories included in the upload may be restricted
		by passing any combination of glob matching strings, compiled regular
		expression objects and custom :class:`~ipfshttpclient.filescanner.Matcher`
		objects. A file or directory will be included if it matches of the
		patterns provided. For regular expressions please note that as predicting
		which directories are relevant to the given pattern is impossible to do
		reliably if *recursive* is set to ``True`` the entire directory hierarchy
		will always be scanned and compared to the given expression even if only
		very few files are actually matched by the expression. To avoid this, pass
		a custom matching class or use glob-patterns instead (which will only
		cause a scan of the directories required to match their value).
		
		Note that unlike the ``ipfs add`` CLI interface this implementation will
		be default include dot-files (“files that are hidden”) – any file or
		directory whose name starts with a period/dot character – in the upload.
		For behaviour that is similar to the CLI command set *pattern* to
		``"**"`` – this enables the default glob behaviour of not matching
		dot-files unless *period_special* is set to ``False`` or the pattern
		actually starts with a period.
		
		Arguments
		---------
		file
			A filepath, path-object, file descriptor or open file object the
			file or directory to add
		recursive
			Upload files in subdirectories, if *file* refers to a directory?
		pattern
			A :mod:`glob` pattern,
			compiled regular expression object or arbitrary matcher used to limit
			the files and directories included as part of adding a directory
			(directories only)
		trickle
			Use trickle-dag format (optimized for streaming) when generating
			the dag; see `the old FAQ <https://github.com/ipfs/faq/issues/218>`_
			for more information
		follow_symlinks
			Follow symbolic links when recursively scanning directories? (directories only)
		period_special
			Treat files and directories with a leading period character (“dot-files”)
			specially in glob patterns? (directories only)
			
			If this is set these files will only be matched by path labels whose
			initial character is a period, but not by those starting with ``?``,
			``*`` or ``[``.
		only_hash
			Only chunk and hash, but do not write to disk
		wrap_with_directory
			Wrap files with a directory object to preserve their filename
		chunker
			The chunking algorithm to use
		pin
			Pin this object when adding
		raw_leaves
			Use raw blocks for leaf nodes. (experimental). (Default: ``True``
			when *nocopy* is True, or ``False`` otherwise)
		nocopy
			Add the file using filestore. Implies raw-leaves. (experimental).
		cid_version
			CID version. Default value is provided by IPFS daemon. (experimental)
		
		Returns
		-------
			Union[dict, list]
				File name and hash of the added file node, will return a list
				of one or more items unless only a single file (not directory)
				was given
Adds a file, several files or directory of files to IPFS
		
		Arguments marked as “directories only” will be ignored unless *file*
		refers to a directory path or file descriptor. Passing a directory file
		descriptor is currently restricted to Unix (due to Python standard
		library limitations on Windows) and will prevent the *nocopy* feature
		from working.
		
		.. 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'}
		
		Directory uploads
		-----------------
		
		By default only regular files and directories immediately below the given
		directory path/FD are uploaded to the connected IPFS node; to upload an
		entire directory tree instead, *recursive* can be set to ``True``.
		Symbolic links and special files (pipes, sockets, devices nodes, …) cannot
		be represented by the UnixFS data structure this call creates and hence
		are ignored while scanning the target directory, to include the targets
		of symbolic links in the upload set *follow_symlinks* to ``True``.
		
		The set of files and directories included in the upload may be restricted
		by passing any combination of glob matching strings, compiled regular
		expression objects and custom :class:`~ipfshttpclient.filescanner.Matcher`
		objects. A file or directory will be included if it matches of the
		patterns provided. For regular expressions please note that as predicting
		which directories are relevant to the given pattern is impossible to do
		reliably if *recursive* is set to ``True`` the entire directory hierarchy
		will always be scanned and compared to the given expression even if only
		very few files are actually matched by the expression. To avoid this, pass
		a custom matching class or use glob-patterns instead (which will only
		cause a scan of the directories required to match their value).
		
		Note that unlike the ``ipfs add`` CLI interface this implementation will
		be default include dot-files (“files that are hidden”) – any file or
		directory whose name starts with a period/dot character – in the upload.
		For behaviour that is similar to the CLI command set *pattern* to
		``"**"`` – this enables the default glob behaviour of not matching
		dot-files unless *period_special* is set to ``False`` or the pattern
		actually starts with a period.
		
		Arguments
		---------
		file
			A filepath, path-object, file descriptor or open file object the
			file or directory to add
		recursive
			Upload files in subdirectories, if *file* refers to a directory?
		pattern
			A :mod:`glob` pattern,
			compiled regular expression object or arbitrary matcher used to limit
			the files and directories included as part of adding a directory
			(directories only)
		trickle
			Use trickle-dag format (optimized for streaming) when generating
			the dag; see `the old FAQ <https://github.com/ipfs/faq/issues/218>`_
			for more information
		follow_symlinks
			Follow symbolic links when recursively scanning directories? (directories only)
		period_special
			Treat files and directories with a leading period character (“dot-files”)
			specially in glob patterns? (directories only)
			
			If this is set these files will only be matched by path labels whose
			initial character is a period, but not by those starting with ``?``,
			``*`` or ``[``.
		only_hash
			Only chunk and hash, but do not write to disk
		wrap_with_directory
			Wrap files with a directory object to preserve their filename
		chunker
			The chunking algorithm to use
		pin
			Pin this object when adding
		raw_leaves
			Use raw blocks for leaf nodes. (experimental). (Default: ``True``
			when *nocopy* is True, or ``False`` otherwise)
		nocopy
			Add the file using filestore. Implies raw-leaves. (experimental).
		cid_version
			CID version. Default value is provided by IPFS daemon. (experimental)
		
		Returns
		-------
			Union[dict, list]
				File name and hash of the added file node, will return a list
				of one or more items unless only a single file (not directory)
				was given
Adds a file several files or directory of files to IPFS Arguments marked as “directories only” will be ignored unless * file * refers to a directory path or file descriptor . Passing a directory file descriptor is currently restricted to Unix ( due to Python standard library limitations on Windows ) and will prevent the * nocopy * feature from working . .. 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 } Directory uploads ----------------- By default only regular files and directories immediately below the given directory path / FD are uploaded to the connected IPFS node ; to upload an entire directory tree instead * recursive * can be set to True . Symbolic links and special files ( pipes sockets devices nodes … ) cannot be represented by the UnixFS data structure this call creates and hence are ignored while scanning the target directory to include the targets of symbolic links in the upload set * follow_symlinks * to True . The set of files and directories included in the upload may be restricted by passing any combination of glob matching strings compiled regular expression objects and custom : class : ~ipfshttpclient . filescanner . Matcher objects . A file or directory will be included if it matches of the patterns provided . For regular expressions please note that as predicting which directories are relevant to the given pattern is impossible to do reliably if * recursive * is set to True the entire directory hierarchy will always be scanned and compared to the given expression even if only very few files are actually matched by the expression . To avoid this pass a custom matching class or use glob - patterns instead ( which will only cause a scan of the directories required to match their value ) . Note that unlike the ipfs add CLI interface this implementation will be default include dot - files ( “files that are hidden” ) – any file or directory whose name starts with a period / dot character – in the upload . For behaviour that is similar to the CLI command set * pattern * to ** – this enables the default glob behaviour of not matching dot - files unless * period_special * is set to False or the pattern actually starts with a period . Arguments --------- file A filepath path - object file descriptor or open file object the file or directory to add recursive Upload files in subdirectories if * file * refers to a directory? pattern A : mod : glob pattern compiled regular expression object or arbitrary matcher used to limit the files and directories included as part of adding a directory ( directories only ) trickle Use trickle - dag format ( optimized for streaming ) when generating the dag ; see the old FAQ <https : // github . com / ipfs / faq / issues / 218 > _ for more information follow_symlinks Follow symbolic links when recursively scanning directories? ( directories only ) period_special Treat files and directories with a leading period character ( “dot - files” ) specially in glob patterns? ( directories only ) If this is set these files will only be matched by path labels whose initial character is a period but not by those starting with ? * or [ . only_hash Only chunk and hash but do not write to disk wrap_with_directory Wrap files with a directory object to preserve their filename chunker The chunking algorithm to use pin Pin this object when adding raw_leaves Use raw blocks for leaf nodes . ( experimental ) . ( Default : True when * nocopy * is True or False otherwise ) nocopy Add the file using filestore . Implies raw - leaves . ( experimental ) . cid_version CID version . Default value is provided by IPFS daemon . ( experimental ) Returns ------- Union [ dict list ] File name and hash of the added file node will return a list of one or more items unless only a single file ( not directory ) was given
def add(self, file: utils.clean_file_t, *files: utils.clean_file_t,
	        recursive: bool = False,
	        pattern: multipart.match_spec_t[ty.AnyStr] = None,
	        trickle: bool = False, follow_symlinks: bool = False,
	        period_special: bool = True, only_hash: bool = False,
	        wrap_with_directory: bool = False, chunker: ty.Optional[str] = None,
	        pin: bool = True, raw_leaves: bool = None, nocopy: bool = False,
	        cid_version: ty.Optional[int] = None,
	        **kwargs: base.CommonArgs):
		"""Adds a file, several files or directory of files to IPFS
		
		Arguments marked as “directories only” will be ignored unless *file*
		refers to a directory path or file descriptor. Passing a directory file
		descriptor is currently restricted to Unix (due to Python standard
		library limitations on Windows) and will prevent the *nocopy* feature
		from working.
		
		.. 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'}
		
		Directory uploads
		-----------------
		
		By default only regular files and directories immediately below the given
		directory path/FD are uploaded to the connected IPFS node; to upload an
		entire directory tree instead, *recursive* can be set to ``True``.
		Symbolic links and special files (pipes, sockets, devices nodes, …) cannot
		be represented by the UnixFS data structure this call creates and hence
		are ignored while scanning the target directory, to include the targets
		of symbolic links in the upload set *follow_symlinks* to ``True``.
		
		The set of files and directories included in the upload may be restricted
		by passing any combination of glob matching strings, compiled regular
		expression objects and custom :class:`~ipfshttpclient.filescanner.Matcher`
		objects. A file or directory will be included if it matches of the
		patterns provided. For regular expressions please note that as predicting
		which directories are relevant to the given pattern is impossible to do
		reliably if *recursive* is set to ``True`` the entire directory hierarchy
		will always be scanned and compared to the given expression even if only
		very few files are actually matched by the expression. To avoid this, pass
		a custom matching class or use glob-patterns instead (which will only
		cause a scan of the directories required to match their value).
		
		Note that unlike the ``ipfs add`` CLI interface this implementation will
		be default include dot-files (“files that are hidden”) – any file or
		directory whose name starts with a period/dot character – in the upload.
		For behaviour that is similar to the CLI command set *pattern* to
		``"**"`` – this enables the default glob behaviour of not matching
		dot-files unless *period_special* is set to ``False`` or the pattern
		actually starts with a period.
		
		Arguments
		---------
		file
			A filepath, path-object, file descriptor or open file object the
			file or directory to add
		recursive
			Upload files in subdirectories, if *file* refers to a directory?
		pattern
			A :mod:`glob` pattern,
			compiled regular expression object or arbitrary matcher used to limit
			the files and directories included as part of adding a directory
			(directories only)
		trickle
			Use trickle-dag format (optimized for streaming) when generating
			the dag; see `the old FAQ <https://github.com/ipfs/faq/issues/218>`_
			for more information
		follow_symlinks
			Follow symbolic links when recursively scanning directories? (directories only)
		period_special
			Treat files and directories with a leading period character (“dot-files”)
			specially in glob patterns? (directories only)
			
			If this is set these files will only be matched by path labels whose
			initial character is a period, but not by those starting with ``?``,
			``*`` or ``[``.
		only_hash
			Only chunk and hash, but do not write to disk
		wrap_with_directory
			Wrap files with a directory object to preserve their filename
		chunker
			The chunking algorithm to use
		pin
			Pin this object when adding
		raw_leaves
			Use raw blocks for leaf nodes. (experimental). (Default: ``True``
			when *nocopy* is True, or ``False`` otherwise)
		nocopy
			Add the file using filestore. Implies raw-leaves. (experimental).
		cid_version
			CID version. Default value is provided by IPFS daemon. (experimental)
		
		Returns
		-------
			Union[dict, list]
				File name and hash of the added file node, will return a list
				of one or more items unless only a single file (not directory)
				was given
		"""
		opts = {
			"trickle": trickle,
			"only-hash": only_hash,
			"wrap-with-directory": wrap_with_directory,
			"pin": pin,
			"raw-leaves": raw_leaves if raw_leaves is not None else nocopy,
			"nocopy": nocopy
		}  # type: ty.Dict[str, ty.Union[str, bool]]
		for option_name, option_value in [
			("chunker", chunker),
			("cid-version", cid_version),
		]:
			if option_value is not None:
				opts[option_name] = option_value
		kwargs.setdefault("opts", {}).update(opts)
		
		# There may be other cases where nocopy will silently fail to work, but
		# this is by far the most obvious one
		if isinstance(file, int) and nocopy:
			raise ValueError("Passing file descriptors is incompatible with *nocopy*")
		
		assert not isinstance(file, (tuple, list)), \
		       "Use `client.add(name1, name2, …)` to add several items"
		multiple = (len(files) > 0)
		to_send  = ((file,) + files) if multiple else file
		body, headers, is_dir = multipart.stream_filesystem_node(
			to_send, chunk_size=self.chunk_size, follow_symlinks=follow_symlinks,
			period_special=period_special, patterns=pattern, recursive=recursive
		)
		
		resp = self._client.request('/add', decoder='json', data=body, headers=headers, **kwargs)
		if not multiple and not is_dir and not wrap_with_directory:
			assert len(resp) == 1
			return base.ResponseBase(resp[0])
		elif kwargs.get("stream", False):
			return base.ResponseWrapIterator(resp, base.ResponseBase)
		return [base.ResponseBase(v) for v in resp]
def add ( self , file : utils . clean_file_t , * files : utils . clean_file_t , recursive : bool = False , pattern : multipart . match_spec_t [ ty . AnyStr ] = None , trickle : bool = False , follow_symlinks : bool = False , period_special : bool = True , only_hash : bool = False , wrap_with_directory : bool = False , chunker : ty . Optional [ str ] = None , pin : bool = True , raw_leaves : bool = None , nocopy : bool = False , cid_version : ty . Optional [ int ] = None , * * kwargs : base . CommonArgs ) : opts = { "trickle" : trickle , "only-hash" : only_hash , "wrap-with-directory" : wrap_with_directory , "pin" : pin , "raw-leaves" : raw_leaves if raw_leaves is not None else nocopy , "nocopy" : nocopy } # type: ty.Dict[str, ty.Union[str, bool]] for option_name , option_value in [ ( "chunker" , chunker ) , ( "cid-version" , cid_version ) , ] : if option_value is not None : opts [ option_name ] = option_value kwargs . setdefault ( "opts" , { } ) . update ( opts ) # There may be other cases where nocopy will silently fail to work, but # this is by far the most obvious one if isinstance ( file , int ) and nocopy : raise ValueError ( "Passing file descriptors is incompatible with *nocopy*" ) assert not isinstance ( file , ( tuple , list ) ) , "Use `client.add(name1, name2, …)` to add several items" multiple = ( len ( files ) > 0 ) to_send = ( ( file , ) + files ) if multiple else file body , headers , is_dir = multipart . stream_filesystem_node ( to_send , chunk_size = self . chunk_size , follow_symlinks = follow_symlinks , period_special = period_special , patterns = pattern , recursive = recursive ) resp = self . _client . request ( '/add' , decoder = 'json' , data = body , headers = headers , * * kwargs ) if not multiple and not is_dir and not wrap_with_directory : assert len ( resp ) == 1 return base . ResponseBase ( resp [ 0 ] ) elif kwargs . get ( "stream" , False ) : return base . ResponseWrapIterator ( resp , base . ResponseBase ) return [ base . ResponseBase ( v ) for v in resp ]