-
Notifications
You must be signed in to change notification settings - Fork 291
Open
Milestone
Description
Recap:
- I discovered SVGs weren't being correctly resized by imagemagick (SVG uploads failing #787), causing SVG uploads to fail. This was fixed by converting to JPG when resizing (convert SVGs to JPEG when editing to avoid errors #788).
- I then discovered that the fix was only valid locally, and AWS uploads were still failing. Fixed in fix SVG thumbs on AWS #789.
Now, I find that even though files upload correctly, Amazon S3 does not supply the correct Content-Type header for SVG files. This makes them unusable in <img> tags.
There is an option to suppy a Content-Type when uploading to S3. I can make it work using two hooks, like so:
def on_uploader(args)
args[:aws_settings][:aws_file_upload_settings] = lambda { |settings|
@suppress_content_type ||= false
settings[:content_type] = params.dig("file_upload")&.content_type unless @suppress_content_type
settings
}
end
# This is needed to prevent using 'svg+xml' content type being applied to resized images, which are JPGs
def uploader_aws_before_upload(_args)
@suppress_content_type = true unless _args[:key].match? /\.svgz?\z/
endBut that still leaves SVG use through AWS not working by default. Plus, if SVGs need a Content-Type applied when uploading to S3, it seems likely that some other file types will need one as well. I think this option should be passed by default.
Since my last two PRs about this haven't completely solved the problem, I'm filing this issue to get comments before attempting another one. Any thoughts on how this should be handled?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels