我有一个Rails 4.2.1应用程序,想要将带有回形针的文件上传到amazon aws s3云空间。
问题是aws开始记录uploadingen,但没有文件写入s3。
模型
class Movie < ActiveRecord::Base
# add File to Movie association on column mo
has_attached_file :movie,
:storage => :s3,
:bucket => 'xxx',
:s3_credentials => {
:bucket => 'xxx',
:access_key_id => 'xxx',
:secret_access_key => 'xxx'
}
# validdates the file type
validates_attachment_content_type :movie, :content_type => /\Avideo\/.*\Z/
end
application.rb中
# Amazon S3 configuration for paperclip
config.paperclip_defaults = {
:storage => :s3,
:s3_host_name => 's3-eu-west-1.amazonaws.com'
}
控制器
class MoviesController < ActionController::Base
layout "application"
# Method to add a new Movie
def addMovie
if request.post?
#@movie = Movie.new(movies_params)
@movie = Movie.new(params[:movie])
if @movie.save
redirect_to :addMovie
end
else
@movie = Movie.new
end
end
private
def movies_params
params.require(:movie).permit(:movietitle, :movieprice, :locked, :moviedescription, :currency, :language, :movie)
end
端
有人有想法会出错吗?