Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix S3 filenames that include a hash #121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/Models/S3File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down