title: Get AWS bucket List Boto/Boto3
body: <p>I have developed a Tornado API which gets me the AWS S3 bucket contents, Below is the code snippet which run perfectly with Boto. However this doesn't work for the buckets in some different location.</p>
  
  <p>The method returns a list(resp) which is consists filename, size, and file type.</p>
  
  <p><strong>Want to achieve similar using Boto3. Tried a lot but Boto3 methods returns the all contents of the s3 bucket with full path.</strong></p>
  
  <pre><code>def post(self):
      try:
          resp = []
          path = self.get_argument('path')
          bucket_name = self.get_argument('bucket_name')
          path_len = len(path)
          conn = S3Connection()
          bucket = conn.get_bucket(bucket_name)
          folders = bucket.list(path, "/")
          for folder in folders:
              if folder.name == path:
                  continue
              if str(folder.name).endswith("/"):
                  file_type = 'd'
                  file_name = str(folder.name)[path_len:-1]
              else:
                  _file_size = self.filesize(folder.size)
                  file_type = 'f'
                  file_name = str(folder.name)[path_len:]
              resp.append({"bucket": bucket_name, "path": path, "name": file_name, "type": file_type,
                           "size": _file_size if file_type == 'f' else ""})
          self.write(json.dumps(resp))
  </code></pre>