title: How to wait the main thread until the AWS S3 file upload finished
body: <p>Based on some user inputs, I want to upload some images(around 10-15) to AWS S3 buckets. Once It completed, front end should display the uploaded images to the client.</p>
  
  <p>But According to my current implementation, Before uploading the images to S3 bucket, the front end page is getting the response from the backend. </p>
  
  <p>I'm using the below code part to upload files to S3.</p>
  
  <pre><code>      AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient();
  
        ObjectMetadata putObjectMetaData = new ObjectMetadata();
        putObjectMetaData.setContentType(contentType);
  
        PutObjectRequest putObject =
            new PutObjectRequest(s3BucketPath, fileName, fileStream, new ObjectMetadata())
                .withCannedAcl(CannedAccessControlList.PublicRead);
        putObject.setMetadata(putObjectMetaData);
  
        PutObjectResult result = s3Client.putObject(putObject);
  </code></pre>
  
  <p>As I understood, S3 upload is going on a separate thread. Is there a way to do the S3 upload from the same main thread. Or is there any other way to wait until the S3 upload is finished?</p>
  
  <p>I really appreciate your replies.</p>