title: Why am I getting a AmazonS3Exception?
body: <p>my task is to encrypt a file that is uploaded to S3. The upload worked fine before the encryption but now after I encrypted the file I get this exception.<br/><br/>
  <code>The XML you provided was not well-formed or did not validate against our published schema</code>
  <br/><br/>
  I added this to the existing Code <br/><br/></p>
  
  <pre><code>        final AwsCrypto crypto = new AwsCrypto();
  
          try (
              final FileInputStream in = new FileInputStream(encryptfile);
              final FileOutputStream out = new FileOutputStream(file);
              final CryptoOutputStream&lt;?&gt; encryptingStream = crypto.createEncryptingStream(crypt, out)) 
          {
              IOUtils.copy(in, encryptingStream);
          }
  </code></pre>
  
  <p><br/>
  My thoughts, Why does AmazonS3 expect a XML-File ? Why not a normal text document ?<br/>
  Is there a Option to change this maybe with the Bucket Policy ?</p>
  
  <p><strong>EDIT</strong> <br/>
  That is the upload code, maybe there is a Issue. I dont understand why it´s working without the encryption.</p>
  
  <pre><code>             File uploaffile = encryptFile(file);
               List&lt;PartETag&gt; partETags = new ArrayList&lt;PartETag&gt;();
               String filename = String.valueOf(System.currentTimeMillis());
  
               InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(awss3bucket, filename);
               InitiateMultipartUploadResult initResponse = amazons3.initiateMultipartUpload(initRequest);
               long partSize = 5 * 1024 * 1024; 
               long contentLength = uploaffile.length();
               long filePosition = 0;
               for (int i = 1; filePosition &lt; contentLength; i++) {
                   partSize = Math.min(partSize, (contentLength - filePosition));
  
                   UploadPartRequest uploadRequest = new UploadPartRequest()
                           .withBucketName(awss3bucket)
                           .withKey(filename)
                           .withUploadId(initResponse.getUploadId())
                           .withPartNumber(i)
                           .withFileOffset(filePosition)
                           .withFile(uploaffile)
                           .withPartSize(partSize);
  
                   PartETag petag = new PartETag(amazons3.uploadPart(uploadRequest).getPartNumber(), amazons3.uploadPart(uploadRequest).getETag());
                   partETags.add(petag);
  
                   filePosition += partSize;
               }
  
               CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest(awss3bucket, filename,
                                                                                              initResponse.getUploadId(), partETags);
  
               amazons3.completeMultipartUpload(compRequest);
  </code></pre>