Carrierwave URL 生成的奇怪行为
我被这个难住了。我正在使用 Carrierwave 和 Fog 来处理 Heroku 上托管的应用程序的缩略图上传,但图像 URL 似乎无法正确生成。
我尝试用三种不同的方式设置我的配置文件:
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'xxx',
:aws_secret_access_key => 'yyy',
}
config.fog_host = 'https://s3.amazonaws.com/statics.gallery.spongecell.com'
end
使图像网址正常工作,但我无法保存新图像,而不会在我的日志中出现疯狂的错误(在说密钥不匹配之后,有几百行长) .)
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'xxx',
:aws_secret_access_key => 'yyy',
}
config.fog_directory = 'statics.gallery.spongecell.com'
config.fog_host = 'https://s3.amazonaws.com/'
end
可以上传,但不能上传图片!图像 URL 中缺少存储桶名称: http://s3.amasonaws.com//uploads /blah/etc
最奇怪的是:
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'xxx',
:aws_secret_access_key => 'yyy',
}
config.fog_host = 'https://s3.amazonaws.com/statics.gallery.spongecell.com'
config.fog_public = false
end
两者都可以工作,但是图像 URL 附加了 s3 密钥(糟糕!)并且速度非常慢。知道这里可能发生什么吗?
提前致谢!
I'm stumped on this one. I'm using Carrierwave with Fog to handle thumbnail uploads for an app hosted on Heroku and the image urls don't seem to be generating properly.
I've tried setting up my config file three different ways:
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'xxx',
:aws_secret_access_key => 'yyy',
}
config.fog_host = 'https://s3.amazonaws.com/statics.gallery.spongecell.com'
end
makes the image urls work properly, but i can't save new images without getting an insane error in my logs (several hundred lines long, after saying the keys don't match.)
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'xxx',
:aws_secret_access_key => 'yyy',
}
config.fog_directory = 'statics.gallery.spongecell.com'
config.fog_host = 'https://s3.amazonaws.com/'
end
makes uploads work, but not images! THe bucket name is missing from the image url: http://s3.amasonaws.com//uploads/blah/etc
And weirdest of all:
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'xxx',
:aws_secret_access_key => 'yyy',
}
config.fog_host = 'https://s3.amazonaws.com/statics.gallery.spongecell.com'
config.fog_public = false
end
makes both work but the image urls are appended with the s3 secret keys (bad!) and it's very slow. Any idea what's possibly happening here?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你根本不需要设置fog_host(如果你将其留空并只设置fog_directory,我认为你应该得到你想要的)。如果您设置fog_public = false,则额外的内容将是使用您的密钥生成的签名,但它实际上不应包含任何秘密(这就是S3允许您临时提供对通常私有的内容的访问权限的方式)。希望有帮助/澄清。
I don't think you should need to set fog_host at all (if you leave it blank and just set fog_directory I think you should get what you want). If you set fog_public=false, the extra stuff will be a signature generated utilizing your secret key, but it shouldn't actually contain any secrets (this is how S3 allows you to temporarily provide access to something which is normally private). Hope that helps/clarifies.