Created
April 22, 2012 02:46
-
-
Save battlejj/2443071 to your computer and use it in GitHub Desktop.
Faux Single Use URLs with ColdFusion and Amazon S3
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
<cfset awsKey = "[YOUR AWS KEY]"> | |
<cfset awsSecret = "[YOUR AWS SECRET]"> | |
<cfset bucket = "[YOUR BUCKET]"> | |
<cfset objectKey = url.file> | |
<cfset s3 = createObject('amazonS3').init(awsKey,awsSecret)> | |
<cfset myURL = s3.s3Url(bucket,objectKey,"regular",2)> | |
<cfoutput>#myURL#</cfoutput> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
<style> | |
iframe { | |
display:none; | |
} | |
</style> | |
</head> | |
<body> | |
<a href="?" id="myDownload" data-file="software/editors/mac/theISOFile.iso">Download Mac Version</a> | |
<script> | |
$('#myDownload').click(function(e){ | |
e.preventDefault(); | |
$.ajax({ | |
url: 'download.cfm', | |
type:'GET', | |
data:{file:$(this).data('file')}, | |
success: function(data){ | |
download($.trim(data)); | |
} | |
}) | |
}); | |
var download = function(url){ | |
$('body').append('<iframe onload="iframeloaded(this)" src="' + url + '"></iframe>'); | |
} | |
var iframeloaded = function(el){ | |
setTimeout( | |
function(){ | |
$(el).remove(); | |
} | |
,1000) | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment