When I import product data or I upload image directly to a product I get the following message (was not uploaded. Filename is too long; must be 90 characters or less)
Recently my magento has been updated and I didn’t have this problem before.
Does anyone know how I can increase the number of characters slightly?
2
Answers
I was able to solve the problem myself.
The file in question is located in the following folder vendormagentoframeworkFile Uploader.php
search for the following code:
Adjusting this file is not the best method, I have to add
For anyone finding this question on Google, I wanted to share additional findings, as I’ve faced the same issue. Perhaps you will find them helpful.
As @Timo already wrote, the limit of
90 characters
is hard-coded in thegetCorrectFileName()
method invendormagentoframeworkFileUploader.php
(in older versions of Magento).Since this method is
static
, writing a plugin is not possible and apparently providing a preference won’t work as well.It seems that there was a fix for this already available in Magento, but only in versions
2.4.2
and2.4.2-p1
. Then, for whatever reasons it got removed. See the related Github issue.Since Magento v2.4.5 the file name length is now limited to 255 characters:
So, until you upgrade your Magento version to
2.4.5
or newer, it seems that making a change in the core code is the only option, either manually or using a composer patch.