validate_bucketname_support ( $bucket )

Validates whether or not the specified Amazon S3 bucket name is valid for path-style access. This method is leveraged by any method that reads from buckets.

Access

public

Parameters

Parameter

Type

Required

Description

$bucket

string

Required

The name of the bucket to validate.

Returns

Type

Description

boolean

Whether or not the bucket name is valid. A value of true means that the bucket name is valid. A value of false means that the bucket name is invalid.

Related Methods

Source

Method defined in services/s3.class.php | Toggle source view (16 lines) | View on GitHub

public function validate_bucketname_support($bucket)
{
    // list_buckets() uses this. Let it pass.
    if ($bucket === '') return true;

    // Validate
    if (
        ($bucket === null || $bucket === false) ||                  // Must not be null or false
        preg_match('/[^(a-z0-9_\-\.)]/i', $bucket) ||               // Must be in the Roman alphabet, period, hyphen or underscore
        !preg_match('/^([a-z]|\d)/i', $bucket) ||                   // Must start with a number or letter
        !(strlen($bucket) >= 3 && strlen($bucket) <= 255) ||        // Must be between 3 and 255 characters long
        preg_match('/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/', $bucket)    // Must not be formatted as an IP address
    ) return false;

    return true;
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback