Skip to content

Instantly share code, notes, and snippets.

@ntulip
Forked from gorsuch/test.cs
Created October 22, 2010 16:32
Show Gist options
  • Save ntulip/640901 to your computer and use it in GitHub Desktop.
Save ntulip/640901 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Text;
using Amazon;
using Amazon.S3;
using Amazon.S3.Model;
namespace AWSUploadTest
{
class Program
{
public static void Main(string[] args)
{
// basic params
string accessKey = "mykey";
string secretAccessKey = "mysecret";
string bucketName = "mybucket";
string keyName = "test.txt";
string sourceFileName = @"c:\temp\upload.txt";
// initialize our client
AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKey, secretAccessKey);
// initialize our request
PutObjectRequest request = new PutObjectRequest();
// we'll use a stream so we can efficiently handle files large or small
FileStream fs = new FileStream(sourceFileName, FileMode.Open);
// setup the request
request.WithInputStream(fs);
request.WithBucketName(bucketName);
request.WithKey(keyName);
// do it!
client.PutObject(request);
// fin!
fs.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment