Skip to content

Commit 1f03c82

Browse files
committed
Fixed S3 uploader clean filename
Removed dependency from baseUrl
1 parent 4b8d1d0 commit 1f03c82

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/FileUploader/S3Uploader.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@ final class S3Uploader extends AbstractFileUploader
1616
/** @var string */
1717
private $s3Bucket;
1818

19-
/** @var string */
20-
private $baseUrl;
21-
2219
/**
2320
* @param S3Client $s3Client
2421
* @param string $s3Bucket
25-
* @param string $baseUrl
2622
* @param ValidatorInterface $validator
2723
* @param TranslatorInterface $translator
2824
* @param string $mimeTypesExtensions
@@ -33,7 +29,6 @@ final class S3Uploader extends AbstractFileUploader
3329
public function __construct(
3430
S3Client $s3Client,
3531
string $s3Bucket,
36-
string $baseUrl,
3732
ValidatorInterface $validator,
3833
TranslatorInterface $translator,
3934
string $mimeTypesExtensions,
@@ -43,7 +38,6 @@ public function __construct(
4338
) {
4439
$this->s3Client = $s3Client;
4540
$this->s3Bucket = $s3Bucket;
46-
$this->baseUrl = $baseUrl;
4741

4842
parent::__construct($validator, $translator, $mimeTypesExtensions, $mimeTypesTypes, $maxFilesize, $imageDriver);
4943
}
@@ -203,6 +197,12 @@ public function getFileSize(string $fileName): ?int
203197
*/
204198
private function cleanFileName(string $fileName): string
205199
{
206-
return substr($fileName, strpos($fileName, $this->baseUrl));
200+
$fileName = parse_url($fileName, PHP_URL_PATH);
201+
202+
if ('/' === substr($fileName, 0, 1)) {
203+
$fileName = substr($fileName, 1);
204+
}
205+
206+
return $fileName;
207207
}
208208
}

0 commit comments

Comments
 (0)