add file upload
This commit is contained in:
3
app/assets/javascripts/volume.coffee
Normal file
3
app/assets/javascripts/volume.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/stylesheets/volume.scss
Normal file
3
app/assets/stylesheets/volume.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the volume controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
@@ -1,4 +1,4 @@
|
||||
class VolumnController < ApplicationController
|
||||
class VolumeController < ApplicationController
|
||||
def info
|
||||
@volumes = Array.new
|
||||
volume = Hash.new
|
||||
@@ -27,4 +27,10 @@ class VolumnController < ApplicationController
|
||||
return `sshpass -pakfm77 ssh -p 2222 root@124.63.216.174 gluster volume info`
|
||||
end
|
||||
|
||||
def file_upload
|
||||
file_name = params[:file]
|
||||
uploader = AvatarUploader.new
|
||||
uploader.store!(file_name)
|
||||
redirect_to '/volume/info'
|
||||
end
|
||||
end
|
||||
2
app/helpers/volume_helper.rb
Normal file
2
app/helpers/volume_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module VolumeHelper
|
||||
end
|
||||
51
app/uploaders/avatar_uploader.rb
Normal file
51
app/uploaders/avatar_uploader.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
# encoding: utf-8
|
||||
|
||||
class AvatarUploader < CarrierWave::Uploader::Base
|
||||
|
||||
# Include RMagick or MiniMagick support:
|
||||
# include CarrierWave::RMagick
|
||||
# include CarrierWave::MiniMagick
|
||||
|
||||
# Choose what kind of storage to use for this uploader:
|
||||
storage :file
|
||||
# storage :fog
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"/home/ubuntu/workspace/app/uploaders"
|
||||
end
|
||||
|
||||
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||
# def default_url
|
||||
# # For Rails 3.1+ asset pipeline compatibility:
|
||||
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
||||
#
|
||||
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
||||
# end
|
||||
|
||||
# Process files as they are uploaded:
|
||||
# process :scale => [200, 300]
|
||||
#
|
||||
# def scale(width, height)
|
||||
# # do something
|
||||
# end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
# version :thumb do
|
||||
# process :resize_to_fit => [50, 50]
|
||||
# end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
# def extension_white_list
|
||||
# %w(jpg jpeg gif png)
|
||||
# end
|
||||
|
||||
# Override the filename of the uploaded files:
|
||||
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||
# def filename
|
||||
# "something.jpg" if original_filename
|
||||
# end
|
||||
|
||||
end
|
||||
BIN
app/uploaders/클라우드_봇.pptx
Normal file
BIN
app/uploaders/클라우드_봇.pptx
Normal file
Binary file not shown.
@@ -39,7 +39,7 @@
|
||||
<li><a><i class="fa fa-edit"></i> Volume <span class="fa fa-chevron-down"></span></a>
|
||||
|
||||
<ul class="nav child_menu" style="display: none">
|
||||
<li><a href="/volumn/info">Info</a>
|
||||
<li><a href="/volume/info">Info</a>
|
||||
</li>
|
||||
<li><a href="#">Create</a>
|
||||
</li>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<%@volumes.each do |t|%>
|
||||
|
||||
<div class="col-md-12 col-sm-1 col-xs-12">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h2>Infomation <small><%=t["Volume Name"]%></small></h2>
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
<div class="x_content">
|
||||
|
||||
<div class="col-md-4 col-sm-1 col-xs-4">
|
||||
<div class="col-md-4 col-sm-4 col-xs-4">
|
||||
Type : <%=t["Type"]%> <br>
|
||||
Volume ID : <%=t["Volume ID"]%> <br>
|
||||
Status : <%=t["Status"]%> <br>
|
||||
@@ -61,14 +61,11 @@
|
||||
performance.readdir-ahead : <%=t["performance.readdir-ahead"]%> <br>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8 col-sm-1 col-xs-8">
|
||||
<div class="col-md-8 col-sm-8 col-xs-8">
|
||||
<p>Drag multiple files to the box below for multi upload or click to select files. This is for demonstration purposes only, the files are not uploaded to any server.</p>
|
||||
<form action="choices/form_upload.html" class="dropzone" style="border: 1px solid #e5e5e5; height: 300px; ">
|
||||
<button type="submit" style="position: absolute; right: 20px; bottom: -10px;">
|
||||
Upload
|
||||
</button>
|
||||
<form action="/file_upload" method="post" enctype="multipart/form-data" class="dropzone" style="border: 1px solid #e5e5e5; height: 300px; overflow:scroll;">
|
||||
</form>
|
||||
<br />
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user