Ruby on rails 带装置的回形针上传至s3
我正在构建一个RESTAPI。它使用mongoid,Desive,现在安装了曲别针mongoid曲别针和aws sdk gems Gemfile.rb 然后,我创建了一个回形针初始值设定项来处理插值:Ruby on rails 带装置的回形针上传至s3,ruby-on-rails,amazon-s3,devise,mongoid,paperclip,Ruby On Rails,Amazon S3,Devise,Mongoid,Paperclip,我正在构建一个RESTAPI。它使用mongoid,Desive,现在安装了曲别针mongoid曲别针和aws sdk gems Gemfile.rb 然后,我创建了一个回形针初始值设定项来处理插值: Paperclip::Attachment.default_options[:filename] = DateTime.now.strftime("%Y%m%d%H%M%S") Paperclip.interpolates ('origin_timestamp') do |style, attac
Paperclip::Attachment.default_options[:filename] = DateTime.now.strftime("%Y%m%d%H%M%S")
Paperclip.interpolates ('origin_timestamp') do |style, attachment|
DateTime.now.strftime("%Y%m%d%H%M%S")
end
对于我在道路上的设计,我补充道:
devise_for :users, :controllers => {:registrations => 'registrations', :sessions => 'sessions'}
我推翻了Desive create函数,如下所示:
def create
build_resource(sign_up_params)
resource_saved = resource.save
yield resource if block_given?
if resource_saved
sign_up(resource_name, resource)
render json: resource
else
clean_up_passwords resource
render json: resource.errors
# @validatable = devise_mapping.validatable?
# if @validatable
# @minimum_password_length = resource_class.password_length.min
# end
# respond_with resource
end
end
private
def sign_up_params
params.permit(:name, :gender, :dob, :telephone, :username, :email, :password, :password_confirmation, :picture)
end
现在,当我启动rails s并使用postman模拟用户注册时,会出现以下错误:
, [2015-05-22T13:57:31.529648 #27393] INFO -- : [paperclip] saving 555f983b6a75736b01030000/original_20150522135731
[AWS S3 403 0.382363 0 retries] put_object(:acl=>:public_read,:bucket_name=>"app-imgs/profile",:content_length=>107729,:content_type=>"image/jpeg",:data=>Paperclip::UploadedFileAdapter: upsellPanel.jpg,:key=>"555f983b6a75736b01030000/original_20150522135731") AWS::S3::Errors::AllAccessDisabled All access to this object has been disabled
Completed 500 Internal Server Error in 576ms
AWS::S3::Errors::AllAccessDisabled (All access to this object has been disabled):
app/controllers/registrations_controller.rb:17:in `create'
我一直在寻找,无法找到解决这个问题的方法。我将配置从远程服务器复制到本地主机。我知道它至少在一个方面起作用,因为我可以在终端中键入aws s3 ls,它会显示我的bucket。bucket名称显示:bucket\u name=>app imgs/profile,更正它 但这是正确的。我想把它上传到哪里,在profile的子文件夹中
def create
build_resource(sign_up_params)
resource_saved = resource.save
yield resource if block_given?
if resource_saved
sign_up(resource_name, resource)
render json: resource
else
clean_up_passwords resource
render json: resource.errors
# @validatable = devise_mapping.validatable?
# if @validatable
# @minimum_password_length = resource_class.password_length.min
# end
# respond_with resource
end
end
private
def sign_up_params
params.permit(:name, :gender, :dob, :telephone, :username, :email, :password, :password_confirmation, :picture)
end
, [2015-05-22T13:57:31.529648 #27393] INFO -- : [paperclip] saving 555f983b6a75736b01030000/original_20150522135731
[AWS S3 403 0.382363 0 retries] put_object(:acl=>:public_read,:bucket_name=>"app-imgs/profile",:content_length=>107729,:content_type=>"image/jpeg",:data=>Paperclip::UploadedFileAdapter: upsellPanel.jpg,:key=>"555f983b6a75736b01030000/original_20150522135731") AWS::S3::Errors::AllAccessDisabled All access to this object has been disabled
Completed 500 Internal Server Error in 576ms
AWS::S3::Errors::AllAccessDisabled (All access to this object has been disabled):
app/controllers/registrations_controller.rb:17:in `create'