-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Issue when configure remote storage with prefix issue fixed #39845
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
base: 2.4-develop
Are you sure you want to change the base?
Issue when configure remote storage with prefix issue fixed #39845
Conversation
Hi @Sathakathulla-S. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
@magento run all tests |
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes incorrect URL concatenation when a storage prefix is configured, ensuring the S3 object URL includes a proper separator before the prefix.
- Insert a forward slash before the trimmed prefix in
AwsS3Factory
. - Maintain trailing slash after the prefix.
Comments suppressed due to low confidence (1)
app/code/Magento/AwsS3/Driver/AwsS3Factory.php:161
- When
prefix
is empty this produces a double slash (//
) in the URL. Consider only adding the slash whenprefix
is non-empty, for example:($prefix !== '' ? '/' . trim($prefix, '\/') : '')
.
$objectUrl = rtrim($client->getObjectUrl($config['bucket'], './'), '/') . '/' . trim($prefix, '\/') . '/';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @Sathakathulla-S,
Thank you for the contribution!
Please sign the CLA and also I guess we can add some automated test in accordance to the DOD.
Thanks
@@ -158,7 +158,7 @@ public function createConfigured( | |||
'cache' => $cache | |||
] | |||
); | |||
$objectUrl = rtrim($client->getObjectUrl($config['bucket'], './'), '/') . trim($prefix, '\\/') . '/'; | |||
$objectUrl = rtrim($client->getObjectUrl($config['bucket'], './'), '/') . '/' . trim($prefix, '\\/') . '/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When prefix is empty this produces a double slash (//) in the URL. Consider only adding the slash when prefix is non-empty, for example: ($prefix !== '' ? '/' . trim($prefix, '/') : '').
Description (*)
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)