title: AWS S3 Bucket Upload/Transfer with boto3
body: <p>I need to upload files to S3 and I was wondering which boto3 api call I should use?</p>
  
  <p>I have found two methods in the boto3 documentation:</p>
  
  <ul>
  <li><a href="http://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Client.upload_file" rel="nofollow">http://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Client.upload_file</a></li>
  <li><a href="http://boto3.readthedocs.io/en/latest/reference/customizations/s3.html" rel="nofollow">http://boto3.readthedocs.io/en/latest/reference/customizations/s3.html</a></li>
  </ul>
  
  <p>Do I use the client.upload_file() ...</p>
  
  <pre><code>#!/usr/bin/python
  import boto3
  session = Session(aws_access_key_id, aws_secret_access_key, region)
  s3 = session.resource('s3')
  s3.Bucket('my_bucket').upload_file('/tmp/hello.txt', 'hello.txt')
  </code></pre>
  
  <p>or do I use S3Transfer.upload_file() ...</p>
  
  <pre><code>#!/usr/bin/python
  import boto3
  session = Session(aws_access_key_id, aws_secret_access_key, region)
  S3Transfer(session).upload_file('/tmp/hello.txt', 'my_bucket', 'hello.txt')
  </code></pre>
  
  <p>Any suggestions would be appreciated. Thanks in advance.</p>
  
  <p>.
  .
  .</p>
  
  <p>possible solution...</p>
  
  <pre><code># http://boto3.readthedocs.io/en/latest/reference/services/s3.html#examples
  # http://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Client.put_object
  # http://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Client.get_object
  
  client = boto3.client("s3", "us-west-1", aws_access_key_id = "xxxxxxxx", aws_secret_access_key = "xxxxxxxxxx")
  
  
  with open('drop_spot/my_file.txt') as file:
    client.put_object(Bucket='s3uploadertestdeleteme', Key='my_file.txt', Body=file)
  
  
  response = client.get_object(Bucket='s3uploadertestdeleteme', Key='my_file.txt')
  
  print("Done, response body: {}".format(response['Body'].read()))
  </code></pre>