fix change stoage file derictory

This commit is contained in:
Jasder 2021-01-28 15:11:47 +08:00 committed by victor
parent 9f7c9d6ec7
commit 6053907828
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
include Ci::DbConnectable
before_action :load_user, only: [:show, :homepage_info, :sync_token, :sync_gitea_pwd, :projects, :watch_users, :fan_users]
@ -79,7 +80,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

@ -322,7 +322,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)