| 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(); |
| 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. |
| 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(); |