From 18dfd61fc1545b28e3b6ab8fcab9dbab5a773452 Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Wed, 6 May 2026 21:58:26 +0200 Subject: [PATCH] files mimetype fix --- apps/api/app/controllers/files_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/api/app/controllers/files_controller.rb b/apps/api/app/controllers/files_controller.rb index 0ba718f..e173f0f 100644 --- a/apps/api/app/controllers/files_controller.rb +++ b/apps/api/app/controllers/files_controller.rb @@ -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