title: Python Boto3: Failed to fetch s3 file
body: <p>Thanks in advance. I'm trying to fetch amazon s3 file after uploading it. But Client error occurs:</p>
  
  <blockquote>
    <p>*** botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found</p>
  </blockquote>
  
  <p>My code:</p>
  
  <pre class="lang-py prettyprint-override"><code>filename = secure_filename(file.filename)
  s3 = boto3.resource('s3')
  s3_bucket = current_app.config['S3_BUCKET']
  s3_dir = current_app.config['S3_DIR']
  client = boto3.client(
      's3',
      aws_access_key_id=current_app.config['AWS_ACCESS_KEY'],
      aws_secret_access_key=current_app.config['AWS_SECRET_ACCESS'],
      region_name='us-west-1',
  )
  
  response = client.put_object(
      ACL='public-read',
      Bucket=s3_bucket,
      Key=f'{s3_dir}/{filename}',
      Body = io.BufferedReader(file).read(),
  )
  
  ## response
  ## {'ResponseMetadata': {'RequestId': 'XXXXX', 'HostId': 'XXXXXXX', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': 'XXXXXXXX', 'x-amz-request-id': '19B2124B56C007AA', 'date': 'Wed, 11 Dec 2019 06:38:48 GMT', 'etag': '"XXXXXXXXXXXX"', 'content-length': '0', 'server': 'AmazonS3'}, 'RetryAttempts': 0}, 'ETag': '"XXXXXXXXXXX"'}
  
  image_file = s3.meta.client.download_file(s3_bucket, filename, f'{s3_dir}/{filename}')
  # Client error occurs
  </code></pre>
  
  <p>I have walked through with <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.download_file" rel="nofollow noreferrer">download_file</a>.</p>