:doc:`CodeCommit <../../codecommit>` / Client / put_file

********
put_file
********



.. py:method:: CodeCommit.Client.put_file(**kwargs)

  

  Adds or updates a file in a branch in an CodeCommit repository, and generates a commit for the addition in the specified branch.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/codecommit-2015-04-13/PutFile>`_  


  **Request Syntax**
  ::

    response = client.put_file(
        repositoryName='string',
        branchName='string',
        fileContent=b'bytes',
        filePath='string',
        fileMode='EXECUTABLE'|'NORMAL'|'SYMLINK',
        parentCommitId='string',
        commitMessage='string',
        name='string',
        email='string'
    )
    
  :type repositoryName: string
  :param repositoryName: **[REQUIRED]** 

    The name of the repository where you want to add or update the file.

    

  
  :type branchName: string
  :param branchName: **[REQUIRED]** 

    The name of the branch where you want to add or update the file. If this is an empty repository, this branch is created.

    

  
  :type fileContent: bytes
  :param fileContent: **[REQUIRED]** 

    The content of the file, in binary object format.

    

  
  :type filePath: string
  :param filePath: **[REQUIRED]** 

    The name of the file you want to add or update, including the relative path to the file in the repository.

     

    .. note::

      

      If the path does not currently exist in the repository, the path is created as part of adding the file.

      

    

  
  :type fileMode: string
  :param fileMode: 

    The file mode permissions of the blob. Valid file mode permissions are listed here.

    

  
  :type parentCommitId: string
  :param parentCommitId: 

    The full commit ID of the head commit in the branch where you want to add or update the file. If this is an empty repository, no commit ID is required. If this is not an empty repository, a commit ID is required.

     

    The commit ID must match the ID of the head commit at the time of the operation. Otherwise, an error occurs, and the file is not added or updated.

    

  
  :type commitMessage: string
  :param commitMessage: 

    A message about why this file was added or updated. Although it is optional, a message makes the commit history for your repository more useful.

    

  
  :type name: string
  :param name: 

    The name of the person adding or updating the file. Although it is optional, a name makes the commit history for your repository more useful.

    

  
  :type email: string
  :param email: 

    An email address for the person adding or updating the file.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'commitId': 'string',
          'blobId': 'string',
          'treeId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **commitId** *(string) --* 

        The full SHA ID of the commit that contains this file change.

        
      

      - **blobId** *(string) --* 

        The ID of the blob, which is its SHA-1 pointer.

        
      

      - **treeId** *(string) --* 

        The full SHA-1 pointer of the tree information for the commit that contains this file change.

        
  
  **Exceptions**
  
  *   :py:class:`CodeCommit.Client.exceptions.RepositoryNameRequiredException`

  
  *   :py:class:`CodeCommit.Client.exceptions.InvalidRepositoryNameException`

  
  *   :py:class:`CodeCommit.Client.exceptions.RepositoryDoesNotExistException`

  
  *   :py:class:`CodeCommit.Client.exceptions.ParentCommitIdRequiredException`

  
  *   :py:class:`CodeCommit.Client.exceptions.InvalidParentCommitIdException`

  
  *   :py:class:`CodeCommit.Client.exceptions.ParentCommitDoesNotExistException`

  
  *   :py:class:`CodeCommit.Client.exceptions.ParentCommitIdOutdatedException`

  
  *   :py:class:`CodeCommit.Client.exceptions.FileContentRequiredException`

  
  *   :py:class:`CodeCommit.Client.exceptions.FileContentSizeLimitExceededException`

  
  *   :py:class:`CodeCommit.Client.exceptions.FolderContentSizeLimitExceededException`

  
  *   :py:class:`CodeCommit.Client.exceptions.PathRequiredException`

  
  *   :py:class:`CodeCommit.Client.exceptions.InvalidPathException`

  
  *   :py:class:`CodeCommit.Client.exceptions.BranchNameRequiredException`

  
  *   :py:class:`CodeCommit.Client.exceptions.InvalidBranchNameException`

  
  *   :py:class:`CodeCommit.Client.exceptions.BranchDoesNotExistException`

  
  *   :py:class:`CodeCommit.Client.exceptions.BranchNameIsTagNameException`

  
  *   :py:class:`CodeCommit.Client.exceptions.InvalidFileModeException`

  
  *   :py:class:`CodeCommit.Client.exceptions.NameLengthExceededException`

  
  *   :py:class:`CodeCommit.Client.exceptions.InvalidEmailException`

  
  *   :py:class:`CodeCommit.Client.exceptions.CommitMessageLengthExceededException`

  
  *   :py:class:`CodeCommit.Client.exceptions.InvalidDeletionParameterException`

  
  *   :py:class:`CodeCommit.Client.exceptions.EncryptionIntegrityChecksFailedException`

  
  *   :py:class:`CodeCommit.Client.exceptions.EncryptionKeyAccessDeniedException`

  
  *   :py:class:`CodeCommit.Client.exceptions.EncryptionKeyDisabledException`

  
  *   :py:class:`CodeCommit.Client.exceptions.EncryptionKeyNotFoundException`

  
  *   :py:class:`CodeCommit.Client.exceptions.EncryptionKeyUnavailableException`

  
  *   :py:class:`CodeCommit.Client.exceptions.SameFileContentException`

  
  *   :py:class:`CodeCommit.Client.exceptions.FileNameConflictsWithDirectoryNameException`

  
  *   :py:class:`CodeCommit.Client.exceptions.DirectoryNameConflictsWithFileNameException`

  
  *   :py:class:`CodeCommit.Client.exceptions.FilePathConflictsWithSubmodulePathException`

  