Created
September 23, 2010 22:00
-
-
Save bbrowning/594467 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /** | |
| * Use this helper method to generate pre-signed S3 urls for use with S3_PING. | |
| * You'll need to generate urls for both the put and delete http methods. | |
| * Example: | |
| * Your AWS Access Key is "abcd". | |
| * Your AWS Secret Access Key is "efgh". | |
| * You want this node to write its information to "/S3_PING/DemoCluster/node1". | |
| * So, your bucket is "S3_PING" and your key is "DemoCluster/node1". | |
| * You want this to expire one year from now, or | |
| * (System.currentTimeMillis / 1000) + (60 * 60 * 24 * 365) | |
| * Let's assume that this equals 1316286684 | |
| * | |
| * Here's how to generate the value for the pre_signed_put_url property: | |
| * String putUrl = S3_PING.generatePreSignedUrl("abcd", "efgh", "put", | |
| * "S3_Ping", "DemoCluster/node1", | |
| * 1316286684); | |
| * | |
| * Here's how to generate the value for the pre_signed_delete_url property: | |
| * String deleteUrl = S3_PING.generatePreSignedUrl("abcd", "efgh", "delete", | |
| * "S3_Ping", "DemoCluster/node1", | |
| * 1316286684); | |
| * | |
| * @param awsAccessKey Your AWS Access Key | |
| * @param awsSecretAccessKey Your AWS Secret Access Key | |
| * @param method The HTTP method - use "put" or "delete" for use with S3_PING | |
| * @param bucket The S3 bucket you want to write to | |
| * @param key The key within the bucket to write to | |
| * @param expirationDate The date this pre-signed url should expire, in seconds since epoch | |
| * @return The pre-signed url to be used in pre_signed_put_url or pre_signed_delete_url properties | |
| */ | |
| public static String generatePreSignedUrl(String awsAccessKey, String awsSecretAccessKey, String method, | |
| String bucket, String key, long expirationDate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment