S3 bucket connection failed (HTTP/1.1 504 GATEWAY_TIMEOUT)
<p>When i am trying to image upload file to my s3 bucket via command line <code>aws s3 cp /Users/shravan40/Downloads/scan1.jpg s3://s3_bucket_name/access_key_id</code> it successfully uploads. But When i try to upload the image through Scala API then, it shows the Gateway timeout. I have set time out time as 2 minutes. </p>

<pre><code>public void connect(){
    conn = new AmazonS3Client(credentials);        
}


public AmazonS3Client(AWSCredentials awsCredentials) {
    this(awsCredentials, new ClientConfiguration());
} 

public void setBucket(String bucketName){
    this.bucketName = bucketName;
    this.baseUrl = "https://s3.us-west-2.amazonaws.com/"+bucketName;
}
</code></pre>

<p>Here is the API code,</p>

<pre><code>post("/api/:version/user/:id/image/upload") {
  CGMetrics.apiProfiler.profile("api.uploadImage") {
    val memberId: Long = params("id").toLong
    if (!AccountService.validateMemberId(memberId))
      APIResponseError(APIResponseCode.NOT_FOUND, "Invalid Member Id")
    else {
      val filePath: String = getUploadedFilePath("file_path", "file")
      val fileName: String = getParam("filename").get.toString

      if (filePath != null) {
        val (uploadImageUrl, resizedImageHeight, resizedImageWidth) = MediaService.uploadImage(memberId, 0, fileName, filePath)
        APIResponseOK(Map("imgUrl" -&gt; uploadImageUrl, "imgHeight" -&gt; resizedImageHeight, "imgWidth" -&gt; resizedImageWidth))
      } else {
        APIResponseError(APIResponseCode.UNPROCESSABLE_ENTITY, "No File Found")
      }
    }
  } 
}
</code></pre>

<p>And getUploadFilePath method,</p>

<pre><code>private def getUploadedFilePath(filePathKey: String = "file_path", fieldName: String = "file")(implicit request: HttpServletRequest): String = {

val filePath: String = getParam(filePathKey) match {
  case Some(x) =&gt; x
  case None =&gt; fileParams.get(fieldName) match {
    case Some(file) =&gt;

      val fileName = file.getName
      val ext = Helper.getFileExtension("/tmp/" + fileName)

      Log.logger(Log.FILE.DEFAULT).debug("file name = " + fileName)
      Log.logger(Log.FILE.DEFAULT).debug("file ext = " + ext)

      val tempFile = File.createTempFile(fileName, "." + ext)
      Helper.writeToFile(tempFile, file.get())
      Log.logger(Log.FILE.DEFAULT).info("Created Temporary Asset : " + fileName + " at  " + tempFile.getAbsolutePath)

      tempFile.getAbsolutePath
    case None =&gt;
      null
  }
}

filePath
}
</code></pre>

<p><strong>Update</strong> : Now files are being uploaded to S3 bucket, but no confirmation for the same.</p>

<p>Any suggestions?</p>