files mimetype fix

This commit is contained in:
2026-05-06 21:58:26 +02:00
parent 565877a09f
commit 18dfd61fc1
+4 -1
View File
@@ -5,7 +5,10 @@ class FilesController < ApplicationController
result = FileService.new.show(FileShowInput.new(path: params[:path]))
case result.type
when :redirect then redirect_to result.url, status: :moved_permanently
when :file then send_file result.path, disposition: "inline"
when :file
ext = File.extname(result.path.to_s).delete_prefix(".")
mime = Mime::Type.lookup_by_extension(ext) || "application/octet-stream"
send_file result.path, disposition: "inline", type: mime
when :not_found then head :not_found
end
end