文件上传

dev_new_shixunsrepository
daiao 5 years ago
parent 5524013569
commit 827d8b568c

@ -19,7 +19,7 @@ class ShixunsController < ApplicationController
:add_file, :jupyter_exec]
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, :apply_public,
:shixun_members_added, :change_manager, :collaborators_delete,
:shixun_members_added, :change_manager, :collaborators_delete, :upload_git_file,
:cancel_apply_public, :cancel_publish, :add_collaborators, :add_file]
before_action :portion_allowed, only: [:copy]
@ -883,7 +883,18 @@ class ShixunsController < ApplicationController
author_name = current_user.real_name
author_email = current_user.git_mail
@content = update_file_content content, @repo_path, @path, author_email, author_name, "Edit by browser"
end
end
def upload_git_file
upload_file = params["file"]
uid_logger("#########################file_params####{params["#{params[:file]}"]}")
raise "未上传文件" unless upload_file
content = upload_file.tempfile.read
author_name = current_user.real_name
author_email = current_user.git_mail
update_file_content(content, @repo_path, author_email, author_name, "upload by browser")
render_ok
end
def add_collaborators
member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")"

@ -279,6 +279,7 @@ Rails.application.routes.draw do
post :set_secret_dir
post :commits
post :file_content
post :upload_git_file
post :update_file
post :close
post :add_file

Loading…
Cancel
Save