title: PlayFramework how can I get correct file path on upload
body: <p>I have play framework version 2.46 and I am uploading files to my amazon S3 account, however I keep getting the path to the tmp file. Here is my code</p>
  
  <pre><code>  def upload = Action (parse.multipartFormData) { implicit request =&gt;
      request.body.file("file").map { file =&gt;
  
  
        val credentials: AWSCredentials = new BasicAWSCredentials("Key", "Secret-key")
        val s3client: AmazonS3 = new AmazonS3Client(credentials)
        val bucketName: String = "myfolder"
  
       val myfile:File= new File(file.filename)
  
        s3client.putObject(new PutObjectRequest(bucketName,file.filename,new File(myfile.getAbsolutePath)))
          Ok("File uploaded")
        }.getOrElse {
        Redirect(routes.Application.index).flashing(
          "error" -&gt; "Missing file")
      }
    }
  </code></pre>
  
  <p>The part that is giving me issues is the <strong>myfile.getAbsolutePath</strong> part it is returning an error file not found. I know exactly why but do not know how to fix it for instance if I have a file at <em>C:\mypictures\Users\bus.jp</em>g then <strong>myfile.getAbsolutePath</strong> would turn it to <em>C:\mypictures\Calc\bus.jpg</em> . My PlayFramework application is named Calc and offcourse that picture does not exist in that location.</p>
  
  <ul>
  <li>Works: new File("C:\mypictures\Users\bus.jpg") = C:\mypictures\Users\bus.jpg</li>
  <li>Does not work new File(myfile.getAbsolutePath)= C:\mypictures\Calc\bus.jpg</li>
  </ul>
  
  <p>How can I fix this so that the correct file location gets uploaded ? I been stuck at this for a few hours</p>