title: How to upload a file to S3 using SSIS?
body: <p>This was my question a few hours ago and just trying to save someone all the effort i had to go through to figure this out. </p>
  
  <p>Basic code on how to upload file to S3 using script task in SSIS. Be sure to add <code>Amazon.S3.dll</code> and <code>Amazon.Core.dll</code> to your references. </p>
  
  <pre><code>using Amazon.S3;
  using Amazon.S3.Transfer;
  using Amazon.S3.Model;
  using System.IO;
  
  namespace tests
  {
      class Program
      {
          static ScriptMain()
          {
              AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
          }
  
          static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
          {
              string path = @"Path to DLLs";
              if (args.Name.Contains("AWSSDK.Core"))
              {
                  return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "AWSSDK.Core.dll"));
              }
              if (args.Name.Contains("AWSSDK.S3"))
              {
                  return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "AWSSDK.S3.dll"));
              }
              return null;
          }
  
          public void Main()
          {
              string filePath = @"Path to file to be uploaded";
              string bucket = "bllcrdtanalytics/Optimization/test"; //bucket name example
              IAmazonS3 s3Client = new AmazonS3Client(Amazon.RegionEndpoint.USWest2);
  
              PutObjectRequest putRequest = new PutObjectRequest();
              putRequest.FilePath = filePath;
              putRequest.Key = Path.GetFileName(filePath);
              putRequest.BucketName = bucket;
              PutObjectResponse response = s3Client.PutObject(putRequest);
  
              Dts.TaskResult = (int)ScriptResults.Success;
          }
      }
  }
  </code></pre>