本文介绍了回报率:无法回形针连接到Amazon S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经决定部署我的应用程序Heroku和我跟随他们的教程。但是,我试着去,现在连接到我的Amazon S3的桶回形针插件和进出口收到此错误:

I have decided to deploy my app to Heroku and I was following their tutorials. However, Im trying to connect to my Amazon S3 bucket with a paperclip plugin right now and Im getting this error:

时ArgumentError在图像#指数

显示应用程序/视图/图片/ index.html.erb,其中线#19提出的:

Showing app/views/images/index.html.erb where line #19 raised:

语法错误就行0,列39:`斗:(MY桶HERE)
  access_key_id:(我的访问密钥ID HERE)
  secret_access_key:(我的秘密访问键的位置)
  
  提取的源(左右线#19):

syntax error on line 0, col 39: `bucket: (MY BUCKET HERE)
access_key_id: (MY ACCESS KEY ID HERE)
secret_access_key: (MY SECRET ACCESS KEY HERE)
'
Extracted source (around line #19):

16:或其;%= H image.created_at%>
  17:或其;%= H image.updated_at%>
  18:
  19:<如果image.img.exists%?那么%>
  20:

<%= image_tag image.img.url(:拇指)%>

16: <%=h image.created_at %>
17: <%=h image.updated_at %>
18:
19: <% if image.img.exists? then %>
20:

<%= image_tag image.img.url(:thumb) %>

有没有照片的连接,上传一个。

There are no photo's attached, upload one.

RAILS_ROOT:C:/用户/马里乌什/网站/ wiw_development

RAILS_ROOT: C:/Users/Mariusz/Sites/wiw_development

应用程序跟踪|框架追踪|完整曲线
  C:/Ruby/lib/ruby/1.8/yaml.rb:133:在负荷
  C:/Ruby/lib/ruby/1.8/yaml.rb:133:在
负荷
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:236:在 find_cr​​edentials
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:176:inparse_credentials'
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:138:在扩展的'
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:137:ininstance_eval'
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:137:在扩展的'
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:269:inextend'
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:269:在 initialize_storage
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:51:ininitialize'
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:在
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:inattachment_for'
  C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:229:在 IMG
  C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:19:in_run_erb_app47views47images47index46html46erb'
  C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:在每个
  C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:in_run_erb_app47views47images47index46html46erb'
  C:/Users/Mariusz/Sites/wiw_development/app/controllers/images_controller.rb:7:`指数

Application Trace | Framework Trace | Full Trace
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in load'
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in
load'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:236:in find_credentials'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:176:in
parse_credentials'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:138:in extended'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:137:in
instance_eval'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/storage.rb:137:in extended'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:269:in
extend'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:269:in initialize_storage'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip/attachment.rb:51:in
initialize'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:in new'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:326:in
attachment_for'
C:/Users/Mariusz/Sites/wiw_development/vendor/plugins/paperclip/lib/paperclip.rb:229:in img'
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:19:in
_run_erb_app47views47images47index46html46erb'
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:in each'
C:/Users/Mariusz/Sites/wiw_development/app/views/images/index.html.erb:12:in
_run_erb_app47views47images47index46html46erb'
C:/Users/Mariusz/Sites/wiw_development/app/controllers/images_controller.rb:7:in `index'

我的文件是这样的:

1)应用程序/模型/ image.rb

1) app/models/image.rb

类图片&LT;的ActiveRecord :: Base的
   has_and_belongs_to_many:对
   validates_ presence_of:img_file_name
   has_attached_file:IMG,:风格=> {:拇指=>100×100#,:页=>400x320>}:存储=>:S3,:s3_credentials =>#{} RAILS_ROOT /config/s3.yml
  结束

2)配置/ s3.yml

2) config/s3.yml

斗:(MY桶HERE)
  access_key_id:(我的访问密钥ID HERE)
  secret_access_key:(我的秘密访问键的位置)

我怎样才能得到它的工作?

How can I get it working?

推荐答案

C:/Ruby/lib/ruby/1.8/yaml.rb:133:负荷 - 这是一个YAML错误。你可能有一个格式错误的YML文件。试试这个code在脚本/控制台:

C:/Ruby/lib/ruby/1.8/yaml.rb:133:in load' - this is a YAML error. You probably have a badly formatted YML file.Try this code in your script/console:

require 'yaml'
my_hash = YAML::load File.read("#{RAILS_ROOT}/config/s3.yml")

下面是我的工作配置的例子:

Below is an example from my working config:

  has_attached_file :data,
  :styles => {
    :small => "100x100#",
    :medium => "400x400#",
    :large => "640x480#"
  },
  :storage => :s3,
  :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
  :path => ":attachment/:id/:style.:extension",
  :bucket => "xxx"

而阳明海运文件:

And the yml file:

development:
  access_key_id: ***
  secret_access_key: ***

这篇关于回报率:无法回形针连接到Amazon S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 13:17