title: Python/ Boto 3: How to retrieve/download files from AWS S3?
body: <p>In Python/Boto 3, Found out that to download a file individually from S3 to local can do the following:</p>
  
  <pre><code>        bucket = self._aws_connection.get_bucket(aws_bucketname)
          for s3_file in bucket.list():
              if filename == s3_file.name:
                  self._downloadFile(s3_file, local_download_directory)
                  break;
  </code></pre>
  
  <p>And to download all files under one chosen directory: </p>
  
  <pre><code>    else:
          bucket = self._aws_connection.get_bucket(aws_bucketname)
          for s3_file in bucket.list():
              self._downloadFile(s3_file, local_download_directory)
  </code></pre>
  
  <p>And helper function <code>_downloadFile()</code>:</p>
  
  <pre><code>  def _downloadFile(self, s3_file, local_download_destination):
          full_local_path = os.path.expanduser(os.path.join(local_download_destination, s3_file.name))
          try:
              print "Downloaded: %s" % (full_local_path)
              s3_file.get_contents_to_filename(full_local_path)
  </code></pre>
  
  <p>But both don’t seem to be working. Using Boto 3 and Python, would like to be able to download all files, as a zip preferably, under a defined directory on S3 to my local. </p>
  
  <p>What could I be doing wrong, and what’s the correct implementation of the parameters? </p>
  
  <p>Thank you in advance, and will be sure to accept/upvote answer</p>
  
  <p><strong>UPDATE CODE</strong>: <code>Getting an error: “AttributeError: 'S3' object has no attribute</code></p>
  
  <pre><code>import sys
  import json
  import os
  import subprocess
  
  import boto3
  from boto.s3.connection import S3Connection
  
  s3 = boto3.resource('s3')
  s3client = boto3.client('s3')
  
  #This works
  for bucket in s3.buckets.all():
      print(bucket.name)
  
  def main():
      #Getting an error: “AttributeError: 'S3' object has no attribute 'download’”
      s3client.download('testbucket', 'fileone.json', 'newfile')
  
  if __name__ == "__main__": main()
  </code></pre>