I’m trying to figure out of DreamObjects are overkill, or can they help me serve some 500MB files for download, but only to specific groups of people who are logged in.
So, I already have some php and a SQL database where people log in and get sent to a specific page based on what group they are part of. What I’d like to know, is of the DreamObjects can protect that download link without too much code fussery, or if it’s just too much.
I’d just use the php features in my current User Login php scripts, but because the files served are so big, I think they are choking on the php memory limits and failing.
So, this is what I’m thinking for a basic download page. Would this code work?
$_REQUEST["gid"] = 2;
// this verifies they are logged in and are part of the right group to get the page, checking a SQL database.
define('AWS_KEY', 'place access key here');
define('AWS_SECRET_KEY', 'place secret key here');
define('AWS_CANONICAL_ID', 'your DHO Username');
define('AWS_CANONICAL_NAME', 'Also your DHO Username!');
$HOST = 'objects.dreamhost.com';
// require the amazon sdk for php library
// Instantiate the S3 class and point it at the desired host
$Connection = new AmazonS3();
// Set the S3 class to use objects.dreamhost.com/bucket
// instead of bucket.objects.dreamhost.com
my $secret_url = $Connection->get_object_url('my-bucket-name', 'secret_plans.txt', '1 hour');
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<a href="<?php $secret_url; ?>">Download just for your group</a>