diff --git a/src/Models/S3File.php b/src/Models/S3File.php index fe99937..adee382 100644 --- a/src/Models/S3File.php +++ b/src/Models/S3File.php @@ -17,10 +17,7 @@ class S3File extends File public function calculateFilesize(): int { - return $this->getS3Client()->headObject([ - 'Bucket' => $this->getBucket(), - 'Key' => $this->getKey() - ])->get('ContentLength'); + return $this->getReadableStream()->getSize(); } public function setS3Client(S3Client $client): self @@ -39,16 +36,6 @@ public function getS3Client(): S3Client return $this->client; } - public function getBucket(): string - { - return parse_url($this->getSource(), PHP_URL_HOST); - } - - public function getKey(): string - { - return ltrim(parse_url($this->getSource(), PHP_URL_PATH), "/"); - } - protected function buildReadableStream(): StreamInterface { $this->getS3Client()->registerStreamWrapper();