使用以下命令将文件保存到公共/数据:
def upload_vault_data
if params[:dump][:file]
uploaded_io = params[:dump][:file]
File.open(Rails.root.join('public', 'data', "data_#{session[:campaign_id]}_#{uploaded_io.original_filename}"), 'w') do |file|
file.write(uploaded_io.read)
end
end
end
这按预期工作,但是如何让用户在文件上传后删除文件?