2

I have a client that wants to sell tutorial videos online. I already got previews of his tutorials streaming from CF (This is public). Now I want to use the c# sdk to generate private, time limited URLs to allow customers who purchased the tutorials to download them for a limited time period. Once the payment has been confirmed, I want to generate a URL and send it to the client via email.

Does CF/.NET SDK support this? Can someone point me at a sample. I have searched Google, and got a little information overload. Different examples from different versions of sdk/management console. Please help me make sense of it all :)

Elad Lachmi
  • 10,406
  • 13
  • 71
  • 133

4 Answers4

4

If you look at the class Amazon.CloudFront.AmazonCloudFrontUrlSigner that has helper methods for creating presigned URL to private distributions. For example this code snippet creates a url that is valid for one day.

var url = AmazonCloudFrontUrlSigner.GetCannedSignedURL(AmazonCloudFrontUrlSigner.Protocol.http, domainName, cloudFrontPrivateKey, file, cloudFrontKeyPairID, DateTime.Now.AddDays(1));

There are other utility methods in that class for adding more specific access rules.

Note this class was added in version 1.5.2.0 of the SDK which came out in late Augest

Norm Johanson
  • 2,964
  • 14
  • 13
2

Yes Amazon S3 as well as CloudFront both support preSignedUrl access. If you want to faster content delivery the you should use CloudFront. Mr. Norm Johanson saying correct. To generate signed url you will need of Public-Private key pair. You can user your own key pair and lets associate with you account of Amazon S3 or you can also generate it at amazon s3 account and download to generate presigned url

Tej Kiran
  • 2,218
  • 5
  • 21
  • 42
1

You can use the GUI or code in S3SignURL to sign your URL

https://github.com/DigitalBodyGuard/S3SignURL

-1

You can't do this with CloudFront (CF), but you can do this directly with S3. You simply call the GetPreSignedURL function to generate a time-limited URL to a specific (private) S3 item. This approach is covered in a tutorial here.

The simplest code sample is this:

AmazonS3 client;

GetPreSignedUrlRequest request = new GetPreSignedUrlRequest();
request.WithBucketName(bucketName);
request.WithKey(objectKey);
request.Verb = HttpVerb.GET; // Default.
request.WithExpires(DateTime.Now.AddMinutes(5));

string url = client.GetPreSignedURL(request);
Pavel Safronov
  • 1,286
  • 10
  • 11
  • Sorry, but this is just not true. CloudFront supports private distributions. I already got this done. I will add my own solution when I get home. – Elad Lachmi Nov 13 '12 at 15:34