Skip to content

Commit 6d5555d

Browse files
authored
Fix S3 filenames that include a hash (#121)
* Fix S3 filenames that include a hash * Use AWS stream wrapper to get S3 file sizes
1 parent 82a5c81 commit 6d5555d

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/Models/S3File.php

+1-14
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ class S3File extends File
1717

1818
public function calculateFilesize(): int
1919
{
20-
return $this->getS3Client()->headObject([
21-
'Bucket' => $this->getBucket(),
22-
'Key' => $this->getKey()
23-
])->get('ContentLength');
20+
return $this->getReadableStream()->getSize();
2421
}
2522

2623
public function setS3Client(S3Client $client): self
@@ -39,16 +36,6 @@ public function getS3Client(): S3Client
3936
return $this->client;
4037
}
4138

42-
public function getBucket(): string
43-
{
44-
return parse_url($this->getSource(), PHP_URL_HOST);
45-
}
46-
47-
public function getKey(): string
48-
{
49-
return ltrim(parse_url($this->getSource(), PHP_URL_PATH), "/");
50-
}
51-
5239
protected function buildReadableStream(): StreamInterface
5340
{
5441
$this->getS3Client()->registerStreamWrapper();

0 commit comments

Comments
 (0)