title: List All objects in S3 with given Prefix in scala
body: <p>I am trying list all objects in AWS S3 Buckets with input Bucket Name &amp; Filter Prefix using following code.</p>
  
  <pre><code>import scala.collection.JavaConverters._
  import com.amazonaws.services.s3.AmazonS3Client
  import com.amazonaws.services.s3.model.ListObjectsV2Request
  
  val bucket_name = "Mybucket"
  val fiter_prefix = "Test/a/"
  
  def list_objects(str: String): mutable.Buffer[String] = {
          val request : ListObjectsV2Request = new ListObjectsV2Request().withBucketName(bucket_name).withPrefix(str)
          var result: ListObjectsV2Result = new ListObjectsV2Result()
          do {
           result = s3_client.listObjectsV2(request)
           val token = result.getNextContinuationToken
           System.out.println("Next Continuation Token: " + token)
           request.setContinuationToken(token)
          }while(result.isTruncated)
          result.getObjectSummaries.asScala.map(_.getKey).size
  }
  
  list_objects(fiter_prefix)
  
  </code></pre>
  
  <p>I have applied continuation method but i am just getting last object list. for example is prefix has 2210 objects i am getting back 210 objects only.</p>
  
  <p>Regards
  Mahi</p>