Using Amazon S3 signed URLs with MC

Anders
Anders
Offline
0
Hi!

First I would like to recommend Germi's custom coding service. For a very reasonable price, he helped us to customize certain things in the current MC to our needs. I found Germi to be very service-minded and willing to go the extra mile to satisfy the customer.

We plan to host our licensed music in a protected storage at Amazon S3 and call it through signed URL:s. This Amazon S3 forum discussion contains the relevant code (obviously, you need to have an account there to use it):

http://developer.amazonwebservices.com/connect/thread.jspa?threadID=18476&tstart=104

And here is the code in question (which requires calling the hmac.php file):

require_once('Crypt/HMAC.php');
//
//
echo getS3Redirect("2007ehsfootball-11-cascade", "/Game/_Cascade%20Entire%20Game.html");
//
//
function getS3Redirect($bucketName, $objectName)
{
$accessKey = "";
$secretKey = "";
// note: breaking this url in to parts so the forum software doesn't try and create a link in my post
$S3_URL = "http:" . "//" . $bucketName . ".s3.amazonaws.com";
$expires = time() + (60*5);
$stringToSign = "GETnnn" . $expires . "n/" . $bucketName . $objectName;
$hasher =& new Crypt_HMAC($secretKey, "sha1");
$sig = $hasher->hash(trim($stringToSign));
$sig = hex2b64($sig);
$sig = rawurlencode(trim($sig));
return "$S3_URL$objectName?AWSAccessKeyId=$accessKey&Expires=$expires&awsSignature=$sig";
}
//
Responses (3)
  • Accepted Answer

    Anders
    Anders
    Offline
    Friday, June 12 2009, 02:36 PM - #Permalink
    0
    ok, my message got cut off so here follows the rest:

    (code continued:)

    //
    //
    function hex2b64($str)
    {
    $raw = '';
    for ($i=0; $i ossible to set the songs folder in MC to be our Amazon S3 bucket, and then set the $S3_URL to correspond to the element in MC that stores the chosen songs folder. And $objectName should correspond to the song filename as stored in the Mc songs database table.

    My question (to you with good PHP skills) is where to place the above functions, where to call it, and then how to place the returned string (the signed URL) in the correct way in the mp3 flash player.

    Any help with this is greatly appreciated (if no help can be offered here, I will ask a skilled friend of mine, but I thought I should ask here first).

    Regards,
    Anders
    The reply is currently minimized Show
  • Accepted Answer

    Anders
    Anders
    Offline
    Friday, June 12 2009, 02:40 PM - #Permalink
    0
    Seems to be some issue with the forum (I could not edit the above). The first paragraph above should have been:

    Obviously, it should be possible to set the songs folder in MC to be our Amazon S3 bucket, and then set the $S3_URL to correspond to the element in MC that stores the chosen songs folder. And $objectName should correspond to the song filename as stored in the Mc songs database table.
    The reply is currently minimized Show
  • Accepted Answer

    Friday, June 12 2009, 03:35 PM - #Permalink
    0
    hello anders

    yes there's an issue with the forum, I dont know why it crops some code.

    send me he code by mail and I'll post it somewhere. or maybe you can just upload it as an attached file to the forum

    by the way, thank you very much for this contributions wich I believe can be very useful. I'm very busy theese days so I haven't had the oportunity to take a deep look at the code, but believe me I will when I get the time to

    :)

    Germi
    The reply is currently minimized Show
Your Reply