Last active
November 18, 2015 23:06
-
-
Save ankona/3faddf3f3f9336e78c68 to your computer and use it in GitHub Desktop.
Compare s3Client.putObject and TransferUtility.upload methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using System.Text; | |
using System; | |
using System.Collections.Generic; | |
using Amazon.DynamoDBv2; | |
using Amazon.DynamoDBv2.Model; | |
using Amazon.Runtime; | |
using Amazon.S3; | |
using System.Configuration; | |
using System.IO; | |
using System.Web; | |
using Amazon; | |
using Amazon.S3.Model; | |
using Amazon.S3.Transfer; | |
namespace bonus | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var basicCredentials = new BasicAWSCredentials( | |
ConfigurationManager.AppSettings["AWSAccessKey"], | |
ConfigurationManager.AppSettings["AWSSecretKey"]); | |
var tokenClient = new Amazon.SecurityToken.AmazonSecurityTokenServiceClient(basicCredentials, RegionEndpoint.USEast1); | |
var credentials = tokenClient.GetSessionToken().Credentials; | |
var s3client = new AmazonS3Client(basicCredentials, RegionEndpoint.USEast1); | |
var filePath = "Z:\\ucms import files\\aws_junk.zip"; | |
var bucketName = "awslabc85ced6e3"; | |
var pr = new PutObjectRequest { | |
BucketName = bucketName, | |
FilePath = filePath | |
}; | |
DateTime startPut = DateTime.Now; | |
var result = s3client.PutObject(pr); | |
DateTime endPut = DateTime.Now; | |
TimeSpan putDuration = (endPut - startPut); | |
Console.WriteLine(String.Format("Using PutObject took: {0} milliseconds.", putDuration.TotalMilliseconds)); | |
DateTime startTransferPut = DateTime.Now; | |
var tu = new TransferUtility(s3client); | |
tu.Upload(filePath, bucketName, "aws_junk_transfer.zip"); | |
DateTime endTransferPut = DateTime.Now; | |
TimeSpan transferDuration = (endTransferPut - startTransferPut); | |
Console.WriteLine(String.Format("Using Upload took: {0} milliseconds.", transferDuration.TotalMilliseconds)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment