Serving Amazon S3 Content by Amazon CloudFront

Serving Amazon S3 Content by Amazon CloudFront



I have this code that updates the sql table to the files url´s when it´s backuped to amazon s3.


$sql = "update " . PVS_DB_PREFIX . "filestorage_files set filename1='" . $file .
"',filename2='" . $new_filename . "',url='" . $url[0] .
"',filesize=" . filesize( $publication_path .
"/" . $file ) . ",width=" . $width . ",height=" . $height .
" where id_parent=" .
$rs->row["id"] . " and item_id=" . $items_mass[$file];
$db->execute( $sql );



Then i delete from local server the files that was moved to amazon s3 by:


//delete files from the local server
for ( $i = 0; $i < count( $delete_mass ); $i++ )
pvs_delete_files( ( int )$delete_mass[$i], false );



Now the files are on the Database with the Amazon S3 url but, i need it to be served on the front by Amazon CloudFront, so i will need to update da sql table again to update de url´s from the files moved to Amazon S3 by:


//cloud front update url on tumbs preview

$sql = "update " . PVS_DB_PREFIX .
"filestorage_files set url='http://www.cloudfront.com/exmaple' item_id=" .
$items_mass[$file] == 0;
$db->execute( $sql );



But... something here is not working right, can any one help me with this ?



Regard´s





Can you explain what is not working right? Update, or access to the file? What kind of error do you get? Also, did you put correct CF url ? (ie. is this just example so you hide true address, or is this real code?)
– Caldazar
Sep 1 at 19:37






Hi, i have hiden the true cloudfront url. i have now fixed it by adding on db a new field, with the cloudfront url by default. Thank you
– azvm
Sep 3 at 11:42




1 Answer
1



Actually the last part of your question not clear, but you should deploy a Cloudfront and set your S3 bucket as the origin. Finally, you have a unique URL for your published Cloudfront, and you can quickly add your file name after the main URL.





Hello! Right, but in this script i´m working on 2 storaged place, first the files are stored on local server, and will be moved next to the S3. I have fixes this by adding on DB, a new column "url2" to the CloudFront.
– azvm
Sep 3 at 11:44



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)