Thursday, January 7, 2010

Using Amazon S3 SDK Pre-signedURL function

Today i was just exploring the amazon sdk. While using the presignedurl function of amazon sdk(C#), i was just curious that what is the server response time , zone. The amazon s3 returns the time in UTC. so simple but i was just curious that if we input time in GMT and it automatically convert it according to requestee IP time zone. i have tried to confirm but first i checked with UTC and it works 100% correctly. The second try i did is that i sent a GMT time and it works too. The amazon convert GMT to UTC according to client location. The sample code look like:

public string GetPreSignedURL(string bucketName, string key)
string url = string.Empty;
AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client("ur access key", "secret key");

GetPreSignedUrlRequest request = new GetPreSignedUrlRequest().WithProtocol(Protocol.HTTPS).WithBucketName(bucketName).WithKey(key).WithExpires(DateTime.UtcNow.AddMinutes(1));
url = client.GetPreSignedURL(request);
catch { }
return url;