diff -urp video/cdn/video_s3/includes/S3.php video_modified/cdn/video_s3/includes/S3.php
--- video/cdn/video_s3/includes/S3.php	2010-05-16 17:10:34.000000000 +0000
+++ video_modified/cdn/video_s3/includes/S3.php	2010-09-09 11:53:06.000000000 +0000
@@ -34,6 +34,7 @@
 * @link http://undesigned.org.za/2007/10/22/amazon-s3-php-class
 * @version 0.4.0
 */
+if(!class_exists('S3')){
 class S3 {
 	// ACL flags
 	const ACL_PRIVATE = 'private';
@@ -1363,3 +1364,4 @@ final class S3Request {
 	}
 
 }
+}
\ No newline at end of file
diff -urp video/cdn/video_s3/includes/amazon_s3.inc video_modified/cdn/video_s3/includes/amazon_s3.inc
--- video/cdn/video_s3/includes/amazon_s3.inc	2010-07-25 07:35:50.000000000 +0000
+++ video_modified/cdn/video_s3/includes/amazon_s3.inc	2010-09-09 21:32:08.000000000 +0000
@@ -20,12 +20,16 @@ class video_amazon_s3 {
   private $ssl;
   private $limit;
   private $bucket;
+  public $authentication_string;
+  public $authentication_lifetime;
 
   public $s3;
 
   public function __construct() {
     $this->access_key = variable_get('amazon_s3_access_key', '');
     $this->secret_key = variable_get('amazon_s3_secret_access_key','');
+    $this->authentication_string_enabled = variable_get('amazon_s3_query_string_authentication_enabled','');
+    $this->authentication_lifetime = variable_get('amazon_s3_query_string_authentication_lifetime','');
     $this->ssl = variable_get('amazon_s3_ssl',FALSE);
     $this->limit = variable_get('amazon_s3_limit',5);
     $this->bucket = variable_get('amazon_s3_bucket', '');
@@ -123,10 +127,16 @@ class video_amazon_s3 {
         $this->working($row->vid);
         $filepath = $video->filepath;
         // get the folder path as file object
-        $filename = $video->filepath;
+        $filename = basename($video->filepath);
         // use the file object as file name
         $video->filename = $filename;
-        if ($this->s3->putObjectFile($filepath, $this->bucket, $filename, S3::ACL_PUBLIC_READ)) {
+        if($this->authentication_string_enabled){
+           $acl_flag = S3::ACL_PRIVATE;
+         }
+        else{
+           $acl_flag = S3::ACL_PUBLIC_READ;
+        }
+        if ($this->s3->putObjectFile($filepath, $this->bucket, $filename, $acl_flag)) {
           // Update our table.
           $video->bucket = $this->bucket;
           $video->vid = $row->vid;
@@ -152,9 +162,14 @@ class video_amazon_s3 {
   }
 
   public function get_authenticated_url($object){
-    $lifetime = 1800;
-    return $this->s3->getAuthenticatedURL($this->bucket, $object, $lifetime);
-  }
+    $expireinterval = $this->authentication_lifetime;
+    $gracetime = $expireinterval + 10;
+    $timestamp = time();
+    $timestamp -= ($timestamp % $expireinterval);
+    $timestamp += $expireinterval + $gracetime;
+    $timestamp = $timestamp - time();
+    return S3::getAuthenticatedURL($this->bucket, $object, $expireinterval, false, ($this->ssl ? true : false));
+   }
 
   
   public function get_object($object, $saveTo = false){
diff -urp video/cdn/video_s3/video_s3.admin.inc video_modified/cdn/video_s3/video_s3.admin.inc
--- video/cdn/video_s3/video_s3.admin.inc	2010-07-08 00:06:50.000000000 +0000
+++ video_modified/cdn/video_s3/video_s3.admin.inc	2010-09-09 11:54:28.000000000 +0000
@@ -32,6 +32,19 @@ function video_s3_admin_settings() {
           '#description' => t('Once saved, you do not need to re-enter your secret key.  If you need to update your key, then fill this out to update it.'),
           '#size' => 50,
   );
+    $form['amazon_s3_query_string_authentication_enabled'] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Enable Query string authentication?'),
+          '#default_value' => variable_get('amazon_s3_query_string_authentication_enabled', FALSE),
+          '#description' => t('Query string authentication generates a new URL which is valid for the specified lifetime. This prevents people from hotlinking to your files. However this may also have a negative impact on caching, because the browser will download the new URL.'),
+  );
+  $form['amazon_s3_query_string_authentication_lifetime'] = array(
+          '#type' => 'textfield',
+          '#title' => t('Query string lifetime'),
+          '#default_value' => variable_get('amazon_s3_query_string_authentication_lifetime', '36000'),
+          '#description' => t('Lifetime in seconds for the query string'),
+          '#size' => 15,
+  );
   //@todo Maybe move this to the admin settings page instead of global?
   $form['amazon_s3_bucket'] = array(
           '#type' => 'textfield',
diff -urp video/cdn/video_s3/video_s3.install video_modified/cdn/video_s3/video_s3.install
--- video/cdn/video_s3/video_s3.install	2010-05-16 17:10:34.000000000 +0000
+++ video_modified/cdn/video_s3/video_s3.install	2010-09-09 11:54:56.000000000 +0000
@@ -104,4 +104,6 @@ function video_s3_uninstall() {
   variable_del('amazon_s3_access_key');
   variable_del('amazon_s3_secret_access_key');
   variable_del('amazon_s3_bucket');
+  variable_del('amazon_s3_query_string_authentication_enabled');
+  variable_del('amazon_s3_query_string_authentication_lifetime');
 }
\ No newline at end of file
diff -urp video/cdn/video_s3/video_s3.module video_modified/cdn/video_s3/video_s3.module
--- video/cdn/video_s3/video_s3.module	2010-07-25 07:35:51.000000000 +0000
+++ video_modified/cdn/video_s3/video_s3.module	2010-09-09 15:14:11.000000000 +0000
@@ -89,7 +89,7 @@ function video_s3_video_update($form, &$
 /**
  * Implementing hook_video_insert
  * @param <type> $element
- * @param <type> $form_state
+ * @param <type> $form_state	
  */
 function video_s3_video_insert(&$element, &$form_state) {
   $file = $element['#value'];
@@ -116,10 +116,17 @@ function video_s3_video_load(&$video) {
   module_load_include('inc', 'video_s3', '/includes/amazon_s3');
   $s3 = new video_amazon_s3;
   if($amazon = $s3->get($video->fid)) {
-    // Fix our filepath
-    $video->filepath = $amazon->filepath;
-    $video->url = $amazon->filepath;
-    $video->extension = pathinfo($amazon->filepath, PATHINFO_EXTENSION);
+      // Fix our filepath
+     if($s3->authentication_string_enabled){
+      $filename = pathinfo($amazon->filepath, PATHINFO_BASENAME);
+      $video->filepath = $s3->get_authenticated_url($filename);
+      $video->url = $video->filepath;
+     }
+    else{
+      $video->filepath = $amazon->filepath;
+      $video->url = $amazon->filepath;
+    }
+      $video->extension = pathinfo($amazon->filepath, PATHINFO_EXTENSION);
   }
 
 }
@@ -136,10 +143,12 @@ function video_s3_get_authenticated_url(
   module_load_include('inc', 'video_s3', '/includes/amazon_s3');
   $s3 = new video_amazon_s3;
   $s3->connect();
-  return $s3->get_authenticated_url($object);
+  if($amazon = $s3->get($object->fid)) {
+   $filename = pathinfo($amazon->filepath, PATHINFO_BASENAME);
+    return $s3->get_authenticated_url($filename);
+ }
 }
 
-
 function video_s3_get_object($object, $save_to = false) {
   module_load_include('inc', 'video_s3', '/includes/amazon_s3');
   $s3 = new video_amazon_s3;
diff -urp video/includes/video_helper.inc video_modified/includes/video_helper.inc
--- video/includes/video_helper.inc	2010-07-25 07:35:50.000000000 +0000
+++ video_modified/includes/video_helper.inc	2010-09-09 11:54:12.000000000 +0000
@@ -53,9 +53,17 @@ class video_helper {
       $conversion = new video_conversion;
       $converted = $conversion->load_converted_video($video->fid);
       if(!$conversion->transcoder_is_wsod()) {
-        $video->filepath = $converted->filepath;
-        $video->url = file_create_url($converted->filepath);
-        $video->extension = pathinfo($converted->filepath, PATHINFO_EXTENSION);
+       
+        if(variable_get('amazon_s3_query_string_authentication_enabled', '') == true){
+          $video->filepath = video_s3_get_authenticated_url($video);
+          $video->url =  $video->filepath;
+          $video->extension = pathinfo($video->filepath, PATHINFO_EXTENSION);
+        }
+        else{
+          $video->filepath = $converted->filepath;
+          $video->url = file_create_url($converted->filepath);
+          $video->extension = pathinfo($converted->filepath, PATHINFO_EXTENSION);
+        }
       }
     }
 
