title: Can I upload excel file into Amazon S3 using AWSSDK.dll
body: <p>Can I upload excel file into the AWS s3 account. What I have fount is that PutObject method provided in the Library can be used to upload the file from a location or using the Stream object. </p>
  
  <pre><code>PutObjectRequest request = new PutObjectRequest()
                  {
                      ContentBody = "this is a test",
                      BucketName = bucketName,
                      Key = keyName,
                      InputStream = stream
                  };
  
                  PutObjectResponse response = client.PutObject(request);
  </code></pre>
  
  <p>Key can be the absolute path on the machine or we give the stream of the file. But my doubt is how we can upload the excel file using the above method</p>
  
  <p>P.S 
  This is the way I am using to convert stream to byte[] but input.ReadByte() is always equal to zero. So my doubt is, is it not reading the excel file?</p>
  
  <pre><code>FileStream str = new FileStream(@"C:\case1.xlsx", FileMode.Open);            
  byte[] arr = ReadFully(str);
  
  
  public static byte[] ReadFully(FileStream input)
          {
              long size = 0;
              while (input.ReadByte() &gt; 0)
              {
                  size++;
              }
              byte[] buffer = new byte[size];
              //byte[] buffer = new byte[16 * 1024];
              using (MemoryStream ms = new MemoryStream())
              {
                  int read;
                  while ((read = input.Read(buffer, 0, buffer.Length)) &gt; 0)
                  {
                      ms.Write(buffer, 0, read);
                  }
                  return ms.ToArray();
              }
          }
  </code></pre>