fix cherry pick merge 458fca9992

This commit is contained in:
Jasder 2021-01-28 15:11:47 +08:00
parent 441589b7f2
commit 82bd15d4ec
3 changed files with 17 additions and 8 deletions

View File

@ -45,7 +45,7 @@ class AttachmentsController < ApplicationController
uid_logger("#########################file_params####{params["#{params[:file_param_name]}"]}")
raise "未上传文件" unless upload_file
folder = edu_setting('attachment_folder')
folder = file_storage_directory
raise "存储目录未定义" unless folder.present?
month_folder = current_month_folder

View File

@ -1,4 +1,5 @@
class UsersController < ApplicationController
include ApplicationHelper
before_action :load_user, only: [:show, :homepage_info, :sync_token, :sync_gitea_pwd, :projects, :watch_users, :fan_users]
before_action :check_user_exist, only: [:show, :homepage_info,:projects, :watch_users, :fan_users]
@ -66,7 +67,7 @@ class UsersController < ApplicationController
def attachment_show
file_name = params[:file_name]
path = params[:path] || edu_setting('attachment_folder')
path = params[:path] || file_storage_directory
send_file "#{path}/#{file_name}", :filename => "#{file_name}",
:type => 'game',
:disposition => 'attachment' #inline can open in browser

View File

@ -323,7 +323,15 @@ module ApplicationHelper
end
def absolute_path(file_path)
File.join(edu_setting('attachment_folder'), file_path)
file_root_directory + File.join(edu_setting('attachment_folder'), file_path)
end
def file_root_directory
Rails.root.to_s
end
def file_storage_directory
file_root_directory + edu_setting('attachment_folder')
end
def local_path(file)