fix missing file format

This commit is contained in:
Alex Turchyn authored and Pete Matsyburka committed 2024-11-25 19:40:21 +02:00
1 parent 8e212e4586
commit e6ca6dfd85
1 file changed
+4 -3
@@ -55,11 +55,12 @@ class TemplatesUploadsController < ApplicationController
tempfile.write(DownloadUtils.call(params[:url]).body)
tempfile.rewind
filename = URI.decode_www_form_component(params[:filename]) if params[:filename].present?
filename ||= File.basename(URI.decode_www_form_component(params[:url]))
file = ActionDispatch::Http::UploadedFile.new(
tempfile:,
filename: File.basename(
URI.decode_www_form_component(params[:filename].presence || params[:url]), '.*'
),
filename:,
type: Marcel::MimeType.for(tempfile)
)