1

我在 Rails 3 中设置了我的 S3 帐户,如下所示:

AWS::S3::DEFAULT_HOST.replace "s3-eu-west-1.amazonaws.com"
#Set up AWS S3
AWS::S3::Base.establish_connection!(
    :access_key_id     => 'itsa',
    :secret_access_key => 'secret'

)
BUCKET='wetten' 

但由于某种原因,它说我的文件不存在。我已授予“所有人”对 S3 中文件的打开/下载权限。

在 Rails 控制台中,对于这个文件

>> AWS::S3::S3Object.exists?('/xml/BWBR0001821.xml', 'wetten')
true

>> AWS::S3::S3Object.find('/xml/BWBR0001821.xml', 'wetten')
AWS::S3::NoSuchKey: No such key `/xml/BWBR0001821.xml'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/object.rb:177:in `find'
    from (irb):11
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
    from C:/Users/Maarten/RubymineProjects/wetten-api/script/rails:6:in `require'
    from C:/Users/Maarten/RubymineProjects/wetten-api/script/rails:6:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

怎么了?

更新:我注意到在 object.rb 中,AWS S3 gem (v0.6.3) 执行以下操作:

bucket = Bucket.find(bucket_name(bucket), :marker => key.previous, :max_keys => 1)

在哪里,并且key是... 什么鬼?这对我来说似乎是一个错误。'/xml/BWBR0001821.xml'key.previous'/xml/BWBR0001821.xmk'

4

1 回答 1

1

发现错误。显然,find 方法在第一个正斜杠时会变得混乱。用作xml/BWBR0001821.xml文件名有效:

>> AWS::S3::S3Object.find('xml/BWBR0001821.xml', 'wetten')
#<AWS::S3::S3Object:0x49387284 '/wetten/xml/BWBR0001821.xml'>
于 2013-07-28T09:47:54.320 回答