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

Limited Filename (path) length #593

Open
AljosaB opened this issue Feb 20, 2024 · 2 comments
Open

Limited Filename (path) length #593

AljosaB opened this issue Feb 20, 2024 · 2 comments

Comments

@AljosaB
Copy link

AljosaB commented Feb 20, 2024

Module version(s) affected

2.1.2

Description

Usually there is a limit of 255 chars for a file name (at least on Windows) and there is the same limit in table "File" because fields "Name" and "Title" are Varchar(255). That is fine (for a file name length).

The customer pointed me to a folder where they wanted to upload a file with the name length of 73 chars and it didn't work. When I first tried to reproduce it, I uploaded it in the root and everything was fine, but when I tried uploading it few levels deeper in the folder hierarchy, I got a broken image with "file doesn't exist".

After trying for some time I found out that it works when the whole path (including all folder names separated with /) is <= 255 characters and it breaks when you get over 255. That is not a nice limit for a bigger sites that have files organised in deep folder structures.

How to reproduce

  • create a folder named "nunc vitae vestibulum felis vel facilisis arcu praesent ultricies eros ipsum ac vehicula neque lacin" (length: 100)
  • create a sub-folder with same name inside it (path length: 200 chars)
  • try to upload a file with 60 chars (for example: "this is a very nice image with 60 chars in the filename.png") (path length = 260 chars / > 255) -> broken file / file doesn't exist
  • try to upload a file with 40 chars (for example: "image with 40 chars in the filename.png") (path length = 240 chars / < 255) -> it works

Additional Context

  • there is a field "FileFilename" with Varchar(255) in the "File" table
  • it seems this field is storing the full file path (/folder1/folder2/filename.ext)
  • by searching over all files I was unable to find where it is declared
  • I was unable to extend it's length by using DataExtension
  • the problem went away after I manually extended the length in DB (tables: File, File_Live, File_Versions)
@maxime-rainville
Copy link
Contributor

maxime-rainville commented Feb 20, 2024

Try adding this snippet to your YML config and running a dev/build. That solved if for me.

SilverStripe\Assets\Storage\DBFile:
  composite_db:
    Filename: "Varchar(512)"

@AljosaB
Copy link
Author

AljosaB commented Feb 21, 2024

That worked! Thanks @maxime-rainville

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

No branches or pull requests

3 participants