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

Wrong attachment path in database - slashes #990

Open
mihau1 opened this issue Nov 19, 2020 · 5 comments
Open

Wrong attachment path in database - slashes #990

mihau1 opened this issue Nov 19, 2020 · 5 comments
Labels

Comments

@mihau1
Copy link

mihau1 commented Nov 19, 2020

image

In database i have wrong slashes in attachments path:
/assets/37\53\75/b7134bcfc363edeec62b097f10629c38679044d6.resized-100x57.jpg

and when i try to use attachment in some node there is a problem with wrong path:

image

But when i'm checking inside media/attachments the link is generating fine:

image

@rchavik
Copy link
Member

rchavik commented Nov 19, 2020

are you testing on windows?

@rchavik rchavik added the Defect label Nov 19, 2020
@mihau1
Copy link
Author

mihau1 commented Nov 20, 2020

Yes, it is on windows

@mihau1
Copy link
Author

mihau1 commented Nov 25, 2020

Any solution?
Could you paste some code-fix?

@rchavik
Copy link
Member

rchavik commented Nov 26, 2020

Try:

diff --git a/FileManager/src/Utility/FileStorageUtils.php b/FileManager/src/Utility/FileStorageUtils.php
index 8c2878399..a99e74a8c 100644
--- a/FileManager/src/Utility/FileStorageUtils.php
+++ b/FileManager/src/Utility/FileStorageUtils.php
@@ -55,7 +55,7 @@ class FileStorageUtils
         $path = null;
         for ($i = 0; $i < $level; $i++) {
             $decrement -= 2;
-            $path .= sprintf("%02d" . DS, substr(str_pad('', 2 * $level, '0') . $string, $decrement, 2));
+            $path .= sprintf("%02d" . '/', substr(str_pad('', 2 * $level, '0') . $string, $decrement, 2));
         }
 
         return $path;

If it works, please PR. Thanks

@mihau1
Copy link
Author

mihau1 commented Nov 26, 2020

Yes, it works - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants