/[drupal]/contributions/modules/flashvideo/plugins/flashvideo_s3/flashvideo_s3.module
ViewVC logotype

Diff of /contributions/modules/flashvideo/plugins/flashvideo_s3/flashvideo_s3.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.4.11, Sun Jul 26 16:47:38 2009 UTC revision 1.1.4.12, Mon Aug 10 00:40:53 2009 UTC
# Line 198  function flashvideo_s3_flashvideo_get_fi Line 198  function flashvideo_s3_flashvideo_get_fi
198      // Get the filename for the file on the Amazon S3 server.      // Get the filename for the file on the Amazon S3 server.
199      $filename = basename($file->filepath);      $filename = basename($file->filepath);
200    
201      // Check to make sure this file exists on the Amazon S3 server.      // If they wish to delete the local files, then we need to do this here...
202      if ($s3->getObjectInfo($s3file->bucket, $filename)) {      if (variable_get('flashvideo_s3_delete', 0) && file_exists(getcwd() .'/'. $file->filepath)) {
203          // Delete the file
204        // If they wish to delete the local files, then we need to do this here...        file_delete($file->filepath);
       if (variable_get('flashvideo_s3_delete', 0) && file_exists(getcwd() .'/'. $file->filepath)) {  
         // Delete the file  
         file_delete($file->filepath);  
       }  
   
       $fileurl = flashvideo_s3_is_distro_ready( $s3file ) ? 'http://' . $s3file->domain : ('http://s3.amazonaws.com/' . $s3file->bucket);  
       $filepath['file'] = $fileurl . '/'. $filename;  
       return $filepath;  
205      }      }
206    
207        $fileurl = flashvideo_s3_is_distro_ready( $s3file ) ? 'http://' . $s3file->domain : ('http://s3.amazonaws.com/' . $s3file->bucket);
208        $filepath['file'] = $fileurl . '/'. $filename;
209        return $filepath;
210    }    }
211    
212    return array();    return array();
# Line 236  function flashvideo_s3_flashvideo_save_f Line 232  function flashvideo_s3_flashvideo_save_f
232    $bucket = variable_get('flashvideo_s3_bucket', str_replace(' ', '-', $conf['site_name']));    $bucket = variable_get('flashvideo_s3_bucket', str_replace(' ', '-', $conf['site_name']));
233    $bucket .= ($bucket == '') ? '' : '-';    $bucket .= ($bucket == '') ? '' : '-';
234    $filepath = drupal_substr($file->filepath, 0, (strrpos($file->filepath, '/')));    $filepath = drupal_substr($file->filepath, 0, (strrpos($file->filepath, '/')));
235      $filepath = rtrim( $filepath, '/' );
236    $bucket .= str_replace('/', '-', $filepath);    $bucket .= str_replace('/', '-', $filepath);
237    
238    // Retrieve a list of all the buckets for this account.    // Retrieve a list of all the buckets for this account.
# Line 244  function flashvideo_s3_flashvideo_save_f Line 241  function flashvideo_s3_flashvideo_save_f
241    // If this bucket is not in the list, then we will want to add this bucket.    // If this bucket is not in the list, then we will want to add this bucket.
242    if ( !$buckets || !(in_array( $bucket, $buckets ))) {    if ( !$buckets || !(in_array( $bucket, $buckets ))) {
243      // Create the bucket.      // Create the bucket.
244        drupal_set_message( $bucket );
245      if ( !$s3->putBucket($bucket, S3::ACL_PUBLIC_READ) ) {      if ( !$s3->putBucket($bucket, S3::ACL_PUBLIC_READ) ) {
246        drupal_set_message(t('S3::putBucket(): Unable to create bucket (it may already exist and/or be owned by someone else)'), 'error');        drupal_set_message(t('S3::putBucket(): Unable to create bucket (it may already exist and/or be owned by someone else)'), 'error');
247        return array();        return array();

Legend:
Removed from v.1.1.4.11  
changed lines
  Added in v.1.1.4.12

  ViewVC Help
Powered by ViewVC 1.1.2