updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -1,6 +1,9 @@
<?php
namespace Aws\S3;
use Aws\Arn\Exception\InvalidArnException;
use Aws\Arn\S3\AccessPointArn;
use Aws\Arn\ArnParser;
use GuzzleHttp\Psr7;
use Psr\Http\Message\UriInterface;
@@ -31,11 +34,25 @@ class S3UriParser
* @param string|UriInterface $uri
*
* @return array
* @throws \InvalidArgumentException
* @throws \InvalidArgumentException|InvalidArnException
*/
public function parse($uri)
{
$url = Psr7\uri_for($uri);
// Attempt to parse host component of uri as an ARN
$components = $this->parseS3UrlComponents($uri);
if (!empty($components)) {
if (ArnParser::isArn($components['host'])) {
$arn = new AccessPointArn($components['host']);
return [
'bucket' => $components['host'],
'key' => $components['path'],
'path_style' => false,
'region' => $arn->getRegion()
];
}
}
$url = Psr7\Utils::uriFor($uri);
if ($url->getScheme() == $this->streamWrapperScheme) {
return $this->parseStreamWrapper($url);
@@ -61,6 +78,19 @@ class S3UriParser
return $result;
}
private function parseS3UrlComponents($uri)
{
preg_match("/^([a-zA-Z0-9]*):\/\/([a-zA-Z0-9:-]*)\/(.*)/", $uri, $components);
if (empty($components)) {
return [];
}
return [
'scheme' => $components[1],
'host' => $components[2],
'path' => $components[3],
];
}
private function parseStreamWrapper(UriInterface $url)
{
$result = self::$defaultResult;