title: Why boto3.client.download_file is appending a string at the end of file name?
body: <p>I need to download files from s3, and I create this code:</p>
  <pre><code>#This function make the download of the files in a bucket 
  def download_dir(s3:boto3.client, bucket:str, directory:str=None) -&gt; None:
      
      #Verify if exist the bucket diretory
      if not os.path.exists(bucket):
                  #Creating the bucket directory
                  os.makedirs(bucket)
      
      # Iterating in s3 list of objects inside of the bucket
      for s3_key in s3.list_objects(Bucket=bucket)['Contents']:
          
          file_name=os.path.join(bucket, s3_key['Key'])
          #If the object is not a directory
          if not s3_key['Key'].endswith(&quot;/&quot;):
              #Verify if the download file was already done  
              if not os.path.exists(file_name):
                  print(s3_key['Key'])
                  real_file_name = s3_key['Key']
                  print(real_file_name)
                  try:
                      s3.download_file(Bucket=bucket,Key=s3_key['Key'], Filename=file_name)
                  except:
                      print(type(real_file_name))
                      s3.download_file(Bucket=bucket, Filename=file_name, Key=real_file_name)
          #If the object is a directory
          else:
              #If the directory doesn't exist
              if not os.path.exists(file_name):
                  #Creating the directory
                  os.makedirs(file_name)
      
  
  s3 = boto3.client('s3',
                  verify=False,
                  aws_access_key_id=aws_dict['aws_access_key_id'], 
                  aws_secret_access_key=aws_dict['aws_secret_access_key'], 
                  aws_session_token=aws_dict['aws_session_token'],
                  region_name=aws_dict['region_name'],
                  config=config
                  )
  
  download_dir(s3, 'MY-BUCKET')
  
  </code></pre>
  <p>But a in specific file, magicly is appending another string at the end of the bucket file name, which brings me an exception:</p>
  <blockquote>
  <p>Traceback (most recent call last):                                                                                                                                                                                                             File &quot;aws_transfer.py&quot;, line 58, in                                                                                                                                                                                                    download_dir(s3, 'bucket')                                                                                                                                                                                                        File &quot;aws_transfer.py&quot;, line 29, in download_dir                                                                                                                                                                                               s3.download_file(Bucket=bucket, Filename=file_name, Key=real_file_name)                                                                                                                                                                    File &quot;/home/gbarbo3/.local/lib/python3.8/site-packages/boto3/s3/inject.py&quot;, line 171, in download_file                                                                                                                                         return transfer.download_file(                                                                                                                                                                                                             File &quot;/home/gbarbo3/.local/lib/python3.8/site-packages/boto3/s3/transfer.py&quot;, line 315, in download_file                                                                                                                                       future.result()                                                                                                                                                                                                                            File &quot;/home/gbarbo3/.local/lib/python3.8/site-packages/s3transfer/futures.py&quot;, line 106, in result                                                                                                                                             return self._coordinator.result()                                                                                                                                                                                                          File &quot;/home/gbarbo3/.local/lib/python3.8/site-packages/s3transfer/futures.py&quot;, line 265, in result                                                                                                                                             raise self._exception                                                                                                                                                                                                                      File &quot;/home/gbarbo3/.local/lib/python3.8/site-packages/s3transfer/tasks.py&quot;, line 126, in <strong>call</strong>                                                                                                                                             return self._execute_main(kwargs)                                                                                                                                                                                                          File &quot;/home/gbarbo3/.local/lib/python3.8/site-packages/s3transfer/tasks.py&quot;, line 150, in _execute_main                                                                                                                                        return_value = self._main(**kwargs)                                                                                                                                                                                                        File &quot;/home/gbarbo3/.local/lib/python3.8/site-packages/s3transfer/download.py&quot;, line 571, in _main                                                                                                                                             fileobj.seek(offset)                                                                                                                                                                                                                       File &quot;/home/gbarbo3/.local/lib/python3.8/site-packages/s3transfer/utils.py&quot;, line 367, in seek                                                                                                                                                 self._open_if_needed()                                                                                                                                                                                                                     File &quot;/home/gbarbo3/.local/lib/python3.8/site-packages/s3transfer/utils.py&quot;, line 350, in _open_if_needed                                                                                                                                      self._fileobj = self._open_function(self._filename, self._mode)                                                                                                                                                                            File &quot;/home/gbarbo3/.local/lib/python3.8/site-packages/s3transfer/utils.py&quot;, line 261, in open                                                                                                                                                 return open(filename, mode)                                                                                                                                                                                                              FileNotFoundError: [Errno 2] No such file or directory: 'bucket/folder/model.tar.gz.c40fF924'</p>
  </blockquote>
  <p>The real file name must to be 'bucket/folder/model.tar.gz'.</p>
  <p>Can anyone help me with that?</p>