Cloudfront

iaminawe - July 13, 2009 - 12:54
Project:Media Mover
Version:6.x-1.x-dev
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I am new to using this Amazon S3 CDN service and was wondering if it works with Media Mover yet?

As I understand it, once Cloudfront is set up, you get a standard S3 bucket url and a cloudfront url which moves and serves your files from Amazons edge servers.

I wanted to ask what would need to be done for Media Mover to move a video file to S3 and then link back to Drupal with the Cloudfront address?
Would cloudfront need to be set up on each file as it is uploaded or is it something I can enable on a S3 bucket that Media Mover could always update the Drupal CCK filefield node with?

Any guidance would be appreciated.

Thanks
Gregg

#1

Jason Ruyle - July 14, 2009 - 18:24

I'm under the impression that you set a cloudfront URL on a specific bucket.
So you may have a bucket named:

static.mywebsite.com

You load your files into that specific bucket.

Then create a distribution on that bucket for cloudfront.

From there you call your files normally:

http://static.mywebsite.com/filename.jpg

It will load from cloudfront (with its price) instead of just the single location and speed of a regular s3 bucket.

#2

iaminawe - July 15, 2009 - 11:06

Thanks for that clarification... I will try it out and report back here

#3

iaminawe - July 20, 2009 - 15:13

I have tried this and it doesn't seem to work for the following reason
When you set up cloudfront distribution on an S3 bucket it keeps your original s3 url as the original and generates a new cloudfront one that looks like this e604721fxaaqy9.cloudfront.net

So if I was using the http://static.mywebsite.com/filename.jpg address it would be using only S3 where if I used the http://e604721fxaaqy9.cloudfront.net/filename.jpg url it would be using the cdn capabilites of cloudfront.

So I guess then that the best thing to do would be to maybe add an extra field in the Media Mover settings that allow you to specify the bucket to use as well as the cloudfront url for that bucket. If nothing is entered into the cloudfront field then it would use the default S3 bucket but if a cloudfront url is specified then it would use that when linking back to the CCK field. Does this sound like a viable solution to this?

I will poke around the code and see if I can make these adjustments but if someone more php capable wants to step in and help out with this that would be great.

Thanks

#4

Jason Ruyle - July 21, 2009 - 23:14

There is a module at:
http://drupal.org/project/cloudfront

It does a general check through imagecache to see if your image is on s3/cloudfront, if it is, it changes the generated link.

I'm not sure if something like this could be done for your media_mover issue.

#5

iaminawe - July 22, 2009 - 09:41

Thanks Jason.

I found that digging in the mm_s3.module file it was fairly straightforward to change the line

// create the return file
return "http://s3.amazonaws.com/". basename($file_path);

to // create the return file
return "http://123123.cloudfront.net/". basename($file_path);

This worked fine for me.

#6

Branndon - September 17, 2009 - 00:00

Ok, this might work to copy the original file over, what what about imagecache files? If the user inserts a "Medium" sized image into their node from imagecache, that is still hosted locally is it not? Anyone have a good work around?

#7

arthurf - September 17, 2009 - 01:39

@iaminawe - there is a setting now in each mm_s3 configuration for the server url- this would be your cloud front URL.

@Branndon - you could use the media mover directory module to move the full image cache directory over to S3 and then use a theme override for the imagecache links

 
 

Drupal is a registered trademark of Dries Buytaert.