DNS compatible bucket names can be used as a subdomain in a URL (e.g.,
".s3.amazonaws.com").
public static isBucketDnsCompatible ( string $bucket ) : boolean | ||
$bucket | string | Bucket name to check. |
return | boolean |
/** * Changes how buckets are referenced in the HTTP request * * @param PreparedEvent $event Event emitted */ public function setBucketStyle(PreparedEvent $event) { $command = $event->getCommand(); $request = $event->getRequest(); $bucket = $command['Bucket']; $path = $request->getPath(); if (!$bucket || isset(self::$exclusions[$command->getName()])) { return; } if ($this->bucketEndpoint) { $path = $this->removeBucketFromPath($path, $bucket); } elseif (!$command['PathStyle'] && S3Client::isBucketDnsCompatible($bucket) && !($request->getScheme() == 'https' && strpos($bucket, '.'))) { // Switch to virtual if PathStyle is disabled, or not a DNS // compatible bucket name, or the scheme is https and there are no // dots in the hostheader (avoids SSL issues). $request->setHost($bucket . '.' . $request->getHost()); $path = $this->removeBucketFromPath($path, $bucket); } // Modify the Key to make sure the key is encoded, but slashes are not. if ($command['Key']) { $path = S3Client::encodeKey(rawurldecode($path)); } $request->setPath($path); }
private function canAccelerate(CommandInterface $command) { return empty(self::$exclusions[$command->getName()]) && S3Client::isBucketDnsCompatible($command['Bucket']); }