Skip to content

Filename is too long exception when importing media images #29377

Closed
@stephansteiner

Description

@stephansteiner

I'm trying to import product images with very long names.
295744_20200804070722_tanzteppich_colorx_150_plus_1004222_16330_chroma_blau_schw_150cm_lfm.jpg
There is a limit in Magento of 90 characters which I don't fully understand.
All unix filesstems support 255 characters, Windows as well, the value column in catalog_product_entity_varchar is 255 characters, the value column in catalog_product_entity_media_gallery is also 255 characters.

The limit of 90 characters is annotated in vendor/magento/framework/File/Uploader.php with the following comment:
// account for excessively long filenames that cannot be stored completely in database

I don't know of any database column less than 255 characters. So the hard limit could be much higher, like 240 characters (the filename in the media gallery will be prepended with the dispretion path of /2/9/ which is 5 extra characters.
Tested on Magento 2.3, on Magento 2.4 there is the same limitation.

Preconditions (*)

  1. Magento 2.4-develop
  2. create a simple product import csv file and prepare a very long filename for the product image. You can use exampled provided along with this bug report.

Steps to reproduce (*)

  1. put a very long named product image into var/import/images/ as described in the guide here https://docs.magento.com/user-guide/system/data-import-product-images.html
  2. In the product csv specify the very long image filename for a product image attribute (like base_image).
  3. Import the product csv file in the Magento backend using System > Data Transfer > Import. For import settings use:
    Entity Type: Products
    Import Behaviour: Add/Update
    Validation Strategy: Stop on Error
    Example CSV file: sample_long.csv.txt

Expected result (*)

  1. Product will be imported without problems and have product image assigned

Actual result (*)

  1. "Check Data" passes, while Import itself will fail due to the fact the product image cannot be saved because of exceeded length

  2. The error message is misleading as it says: "1. Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s): 1"
    image

  3. When using a shorter image name, import works.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Component: FileFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P3May be fixed according to the position in the backlog.Progress: doneReported on 2.4.0Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions