|
|
@ -469,6 +469,8 @@ class ShixunsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
# 实训测试集附件
|
|
|
|
# 实训测试集附件
|
|
|
|
def upload_data_sets
|
|
|
|
def upload_data_sets
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
|
|
|
|
upload_file = params["file"]
|
|
|
|
upload_file = params["file"]
|
|
|
|
raise "未上传文件" unless upload_file
|
|
|
|
raise "未上传文件" unless upload_file
|
|
|
|
folder = edu_setting('shixun_folder')
|
|
|
|
folder = edu_setting('shixun_folder')
|
|
|
@ -492,7 +494,6 @@ class ShixunsController < ApplicationController
|
|
|
|
@attachment.digest = digest
|
|
|
|
@attachment.digest = digest
|
|
|
|
@attachment.author_id = current_user.id
|
|
|
|
@attachment.author_id = current_user.id
|
|
|
|
@attachment.disk_directory = tpm_folder
|
|
|
|
@attachment.disk_directory = tpm_folder
|
|
|
|
@attachment.cloud_url = remote_path
|
|
|
|
|
|
|
|
@attachment.container_id = @shixun.id
|
|
|
|
@attachment.container_id = @shixun.id
|
|
|
|
@attachment.container_type = @shixun.class.name
|
|
|
|
@attachment.container_type = @shixun.class.name
|
|
|
|
@attachment.attachtype = 2
|
|
|
|
@attachment.attachtype = 2
|
|
|
@ -501,6 +502,10 @@ class ShixunsController < ApplicationController
|
|
|
|
logger.info "文件已存在,id = #{@attachment.id}, filename = #{@attachment.filename}"
|
|
|
|
logger.info "文件已存在,id = #{@attachment.id}, filename = #{@attachment.filename}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
render_ok
|
|
|
|
render_ok
|
|
|
|
|
|
|
|
rescue => e
|
|
|
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
|
|
|
tip_exception(e.message)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 多文件删除
|
|
|
|
# 多文件删除
|
|
|
@ -1105,4 +1110,16 @@ private
|
|
|
|
ext
|
|
|
|
ext
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def delete_file(file_path)
|
|
|
|
|
|
|
|
File.delete(file_path) if File.exist?(file_path)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def md5_file(temp_file)
|
|
|
|
|
|
|
|
md5 = Digest::MD5.new
|
|
|
|
|
|
|
|
temp_file.rewind
|
|
|
|
|
|
|
|
while (buffer = temp_file.read(8192))
|
|
|
|
|
|
|
|
md5.update(buffer)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
md5.hexdigest
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|