title: Uploading files to the s3 bucket
body: <p>I am trying to upload my files to the s3 bucket, but i don't want that file to be uploaded from my local machine instead when some one uses the application and uploads a file the same should be directly uploaded to my s3 bucket.!! Is there a way to do this?(code should be in .net)</p>
  
  <pre><code>            string filekey = filePath.Substring(filePath.LastIndexOf('\\') + 1);
              using (MemoryStream filebuffer = new MemoryStream(File.ReadAllBytes(filePath)))
              {
                  PutObjectRequest putRequest = new PutObjectRequest
                  {
                      BucketName = this.awsBucketName,
                      Key = "GUARD1" + "/" + filekey,
                      InputStream = filebuffer,
                      ContentType = "application/pkcs8",
                  };
  </code></pre>
  
  <p>This is what i am doing..which in turn creates a folder in the bucket and takes the file path from the local machine and the same is uploaded to the bucket.</p>
  
  <p>What i need is that the file shouldn't be saved in the local machine and instead be taken directly from the application to the s3 bucket.</p>
  
  <p>This is WriteIntoS3 method:</p>
  
  <pre><code>string filekey = filePath.Substring(filePath.LastIndexOf('\\') + 1);
                  using (MemoryStream filebuffer = new MemoryStream(File.ReadAllBytes(filePath)))
                  {
                      PutObjectRequest putRequest = new PutObjectRequest
                      {
                          BucketName = this.awsBucketName,
                          Key = "GUARD1" + "/" + filekey,
                          InputStream = filebuffer,
                          ContentType = "application/pkcs8",
                      };
  
                      client.PutObject(putRequest);
  
                      GetPreSignedUrlRequest expiryUrlRequest = new GetPreSignedUrlRequest();
                      expiryUrlRequest.BucketName = this.awsBucketName;
                      expiryUrlRequest.Key = filekey;
                      expiryUrlRequest.Expires = DateTime.Now.AddDays(ExpiryDays);
  
                      string url = client.GetPreSignedURL(expiryUrlRequest);
                      return url;
                  }
  </code></pre>