fix change stoage file derictory
This commit is contained in:
parent
a93baa908f
commit
458fca9992
|
@ -45,7 +45,7 @@ class AttachmentsController < ApplicationController
|
||||||
uid_logger("#########################file_params####{params["#{params[:file_param_name]}"]}")
|
uid_logger("#########################file_params####{params["#{params[:file_param_name]}"]}")
|
||||||
raise "未上传文件" unless upload_file
|
raise "未上传文件" unless upload_file
|
||||||
|
|
||||||
folder = edu_setting('attachment_folder')
|
folder = file_storage_directory
|
||||||
raise "存储目录未定义" unless folder.present?
|
raise "存储目录未定义" unless folder.present?
|
||||||
|
|
||||||
month_folder = current_month_folder
|
month_folder = current_month_folder
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
|
include ApplicationHelper
|
||||||
include Ci::DbConnectable
|
include Ci::DbConnectable
|
||||||
|
|
||||||
before_action :load_user, only: [:show, :homepage_info, :sync_token, :sync_gitea_pwd, :projects, :watch_users, :fan_users]
|
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
|
def attachment_show
|
||||||
file_name = params[:file_name]
|
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}",
|
send_file "#{path}/#{file_name}", :filename => "#{file_name}",
|
||||||
:type => 'game',
|
:type => 'game',
|
||||||
:disposition => 'attachment' #inline can open in browser
|
:disposition => 'attachment' #inline can open in browser
|
||||||
|
|
|
@ -322,7 +322,15 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def absolute_path(file_path)
|
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
|
end
|
||||||
|
|
||||||
def local_path(file)
|
def local_path(file)
|
||||||
|
|
Loading…
Reference in New Issue