Search code examples
ruby-on-railsrubyrails-activestorage

Active Storage: filenames with special characters


In my application, users can change the background image of a banner. They upload the file using Simple Form and Active Storage. It's working correctly but we had a user trying to upload a file name banner-website.png (2).png. The file is uploaded and saved but doesn't appear as a background image. I guess this happens because of special characters in the filename.

What is recommended to avoid such situations? Do we need to sanitize file names?


Solution

  • I've found the solution here: Rails Active Storage - Background Image invalid property?

    Adding a single quote around the URL solved it.