fix missing file format

This commit is contained in:
Alex Turchyn
2024-11-25 18:59:37 +02:00
committed by Pete Matsyburka
parent 8e212e4586
commit e6ca6dfd85
@@ -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)
)