Amazon_S3_And_CloudFront::get_s3object_region PHP Method

get_s3object_region() public method

Get the region of the bucket stored in the S3 metadata.
public get_s3object_region ( array $s3object, integer $post_id = null ) : string | WP_Error
$s3object array
$post_id integer - if supplied will update the s3 meta if no region found
return string | WP_Error - region name
    function get_s3object_region($s3object, $post_id = null)
    {
        if (!isset($s3object['region'])) {
            // if region hasn't been stored in the s3 metadata retrieve using the bucket
            $region = $this->get_bucket_region($s3object['bucket']);
            if (is_wp_error($region)) {
                return $region;
            }
            $s3object['region'] = $region;
            if (!is_null($post_id)) {
                // retrospectively update s3 metadata with region
                update_post_meta($post_id, 'amazonS3_info', $s3object);
            }
        }
        return $s3object['region'];
    }
Amazon_S3_And_CloudFront