Customizing Allowed File Types in Shopware 6: A Community Discussion

Extending Shopware 6 File Uploads: A Community Deep Dive into Custom File Types

The ability to upload diverse file types is crucial for many e-commerce businesses, especially those selling digital products. This Shopware forum topic, "Dateitypen hochladen" (Upload File Types), delves into a common challenge faced by merchants migrating from Shopware 5 to Shopware 6: customizing the list of allowed file extensions for uploads.

The Challenge: Missing Configuration for Custom File Types

The discussion kicks off with user 'jolandos' highlighting a key difference between Shopware 5 and 6. In Shopware 5, extending the list of allowed file types (e.g., to include .epub for e-books) was straightforward, often managed via a YAML file within config/packages. However, in Shopware 6, this specific configuration file appears to be missing, leaving users unsure how to add new file extensions.

Another user, 'Max_Shop', provides important context, explaining that strict file type restrictions are a security measure. Shopware performs both client-side and server-side checks to prevent the upload of potentially malicious files. This underscores why simply bypassing these checks isn't an option and why a proper configuration method is needed.

The Proposed Solution: Manual YAML Configuration

Community member 'R4M' steps in to offer guidance. The core of the solution involves manually creating a configuration file named z-shopware.yaml within the config/packages directory. This file allows overriding default Shopware settings. The initial advice, however, faced a minor but critical error.

'jolandos' initially attempted to use private_allowed_extensions within the YAML file, as shown below:

shopware:
  filesystem:
    private_allowed_extensions: ["epub", "jpg", "jpeg", "png", "webp", "gif", "svg", "bmp", "tiff", "tif", "eps", "webm", "mkv", "flv", "ogv", "ogg", "mov", "mp4", "avi", "wmv", "pdf", "aac", "mp3", "wav", "flac", "oga", "wma", "txt", "doc", "ico", "zip", "rar", "stl"]

Despite adding epub and clearing the cache, the upload still failed with the standard "file type not allowed" message.

The Critical Correction: Using 'allowed_extensions'

'R4M' quickly identified the issue: the correct key to use is allowed_extensions, not private_allowed_extensions. The corrected YAML snippet should look like this:

shopware:
  filesystem:
    allowed_extensions: ["epub", "jpg", "jpeg", "png", "webp", "gif", "svg", "bmp", "tiff", "tif", "eps", "webm", "mkv", "flv", "ogv", "ogg", "mov", "mp4", "avi", "wmv", "pdf", "aac", "mp3", "wav", "flac", "oga", "wma", "txt", "doc", "ico", "zip", "rar", "stl"]

This change, along with clearing the Shopware cache, was presented as the definitive solution.

Unresolved Outcome and Community Feedback

Unfortunately, even after implementing the corrected YAML configuration and clearing the cache, 'jolandos' reported that the issue persisted, still receiving the generic "file type not allowed" error. The thread concludes without a definitive working solution for the original poster, leaving the problem unresolved within the discussion.

User 'raymond-de' suggests that this functionality – making it easier to extend allowed file types – should be proposed on the Shopware Feedback Portal. This highlights a perceived gap in Shopware's user-friendliness or documentation regarding this specific configuration, especially for non-programmers.

Key Takeaways for Shopware Merchants and Developers:

  • Shopware 6 requires manual creation of config/packages/z-shopware.yaml to extend allowed file types.
  • The correct YAML key for this configuration is shopware.filesystem.allowed_extensions.
  • Always clear the Shopware cache after making configuration changes.
  • The community thread indicates that even with the correct configuration, users might face persistent issues, suggesting further troubleshooting or a deeper understanding of Shopware's file handling might be necessary.
  • There's a clear community desire for a more streamlined or better-documented way to manage allowed file types in Shopware 6.

While the thread provides valuable insight into the intended configuration method, its unresolved outcome for the original poster suggests that implementing this solution might still require further investigation or a more comprehensive guide to ensure success.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools