title: AWS S3 .csv file is empty
body: <p>I am facing a problem when creating a .csv file on the AWS S3 bucket. I have tried the PutObjectRequest and the TransferUtility libraries. </p>
  
  <p>I think it is how I'm writing to the csvText.csv file. The data is written in memory so I can't store the data physically in a file on the server.  </p>
  
  <p>Issue: The file (userData.csv) is created but doesn't contain any data. </p>
  
  <p>When I run this application locally on my pc it will create and populate the file in S3. But not the application is called through the AWS URL, the file is created but no data is populated in the csv.</p>
  
  <p>Environment and workflow:
  My .NET web application (GatherUserData) sits on a EC2 instance which is called by a CreateUser() method from a thirdparty application(CS).</p>
  
  <p>My application then calls (CS) with a GET request. GETS user data and then Creates a CSV file and places it in a S3 bucket. </p>
  
  <p>My code:</p>
  
  <pre><code>public string ExportUserDataCSVFile(GetUserData userData)
      {
          csvText = new StringBuilder();
          try
          {
              Data1.Customfield[] customeFields = userData.data.customFields;
              if (userData != null)
              {
                  //header
                  csvText.AppendLine(GetSingleUserCSVHeader());
  
                  //UserID
                  csvText.Append(userData.data.userId);
              }
          catch (Exception e)
  
          {
              Console.WriteLine(e.Message);
          }
  
          return csvText.ToString();
  </code></pre>
  
  <p>}</p>
  
  <p>CreateCsvInAws class:</p>
  
  <pre><code>public static void CreateCsvInAws(string csvText)
      {
  
  
          try
          {
  
              MemoryStream ms = new MemoryStream();
              BinaryWriter bw = new BinaryWriter(ms);
              bw.Write(csvText.ToCharArray());
              bw.Flush();
              bw.Close();
  </code></pre>
  
  <p>s3Client = new AWSClient();</p>
  
  <pre><code>                PutObjectRequest pr = new PutObjectRequest
  
              {
  
                  BucketName = bucketName,
                  Key = keyName,
                  ContentBody = csvText, {I can see the user data here, but it doesn't get written to the file}
                  ContentType = "application/octet-stream",
                  CannedACL = "bucket-owner-full-control"
              };
  
              PutObjectResponse response = s3Client.PutObject(pr);
          }
          catch (AmazonS3Exception e)
          {
              Console.WriteLine("Error encountered '{0}' when writing");
          }
          catch (Exception e)
          {
              Console.WriteLine("unknown error '{0}' again");
          }
  
      }
  </code></pre>