diff -Nuar amazons3-ori/AmazonS3StreamWrapper.inc amazons3/AmazonS3StreamWrapper.inc --- amazons3-ori/AmazonS3StreamWrapper.inc 2012-04-21 22:24:13.000000000 +0800 +++ amazons3/AmazonS3StreamWrapper.inc 2013-11-11 17:27:13.000000000 +0800 @@ -916,6 +916,10 @@ else { try { $this->s3 = new AmazonS3(); + $this->s3->set_region(variable_get('amazons3_region', AmazonS3::REGION_US_E1)); + if (strpos($bucket, '.') !== FALSE) { + $this->s3->enable_path_style(); + } $this->bucket = $bucket; } catch(RequestCore_Exception $e){ diff -Nuar amazons3-ori/amazons3.module amazons3/amazons3.module --- amazons3-ori/amazons3.module 2012-04-21 22:24:13.000000000 +0800 +++ amazons3/amazons3.module 2013-11-11 17:25:31.000000000 +0800 @@ -58,6 +58,15 @@ function amazons3_admin() { $form = array(); + $library = libraries_load('awssdk'); + if(!$library['loaded']) { + drupal_set_message(t('Unable to load the AWS SDK. Please check you have installed the library correctly and configured your S3 credentials.'), 'warning'); + return $form; + } + else if(!class_exists('AmazonS3')) { + drupal_set_message(t('Cannot load AmazonS3 class. Please check the awssdk is installed correctly'), 'warning'); + return $form; + } + $form['amazons3_bucket'] = array( '#type' => 'textfield', '#title' => t('Default Bucket Name'), @@ -65,6 +74,23 @@ '#required' => TRUE, ); + $form['amazons3_region'] = array( + '#type' => 'select', + '#title' => t('Bucket region'), + '#default_value' => variable_get('amazons3_region', AmazonS3::REGION_US_E1), + '#required' => true, + '#options' => array( + AmazonS3::REGION_US_E1 => t('US Standard'), + AmazonS3::REGION_US_W1 => t('US West (Oregon) Region'), + AmazonS3::REGION_US_W2 => t('US West (Northern California) Region'), + AmazonS3::REGION_EU_W1 => t('EU (Ireland) Region'), + AmazonS3::REGION_APAC_SE1 => t('Asia Pacific (Singapore) Region'), + AmazonS3::REGION_APAC_SE2 => t('Asia Pacific (Sydney) Region'), + AmazonS3::REGION_APAC_NE1 => t('Asia Pacific (Tokyo) Region'), + AmazonS3::REGION_SA_E1 => t('South America (Sao Paulo) Region'), + ), + ); + $form['amazons3_cache'] = array( '#type' => 'checkbox', '#title' => t('Enable database caching'), @@ -141,6 +167,10 @@ else { try { $s3 = new AmazonS3(); + $s3->set_region($form_state['values']['amazons3_region']); + if (strpos($bucket, '.') !== FALSE) { + $s3->enable_path_style(); + } // test connection $user_id = $s3->get_canonical_user_id(); if(!$user_id['id']) {