title: Exception parsing XML file on AWS S3
body: <p>When I parse an XML file on AWS S3, I get an exception.  When I parse the same file on my hard drive, it works fine.</p>
  
  <p>Here is how I parse the file on AWS S3:</p>
  
  <pre><code>import com.amazonaws.services.s3.AmazonS3
  import scala.io.{BufferedSource, Source}
  import com.amazonaws.services.s3.model.GetObjectRequest
  
    private def loadNode(s3Client: AmazonS3, bucket: String, filePath: String) = {
      val s3Object = s3Client.getObject(new GetObjectRequest(bucket, filePath))
  
      val source: BufferedSource = Source.fromInputStream(s3Object.getObjectContent)
      val joinedLines = source.mkString
      val node = Try(xml.XML.loadString(joinedLines))
  
      node
    }
  </code></pre>
  
  <p>When I do so, I get the following exception:</p>
  
  <pre><code>org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
  </code></pre>
  
  <p>Here is how I load the file locally:</p>
  
  <pre><code>val xml = XML.loadFile("/Users/paulreiners/data/my-file.xml")
  </code></pre>
  
  <p>This works just fine.</p>
  
  <p>When I executing the following code:</p>
  
  <pre><code>System.out.println("Content-Type: " + s3Object.getObjectMetadata.getContentType)
  </code></pre>
  
  <p>it prints:</p>
  
  <pre><code>Content-Type: application/octet-stream
  </code></pre>
  
  <p>I don't know if that is helpful.</p>
  
  <p>So what is going wrong in the S3 case?</p>