[英]Paperclip + AWS S3, Prefixing remote path with my local path
I'm using Paperclip with a Rails 4 app and Amazon S3 storage. 我正在将Paperclip与Rails 4应用程序和Amazon S3存储一起使用。 On my development machine, the site is running at
在我的开发机器上,该网站的运行位置为
/Users/Jeff/Sites/example.com/web
When I upload a file with Paperclip to S3, the remote path in S3 inherits my local folder structure. 当我使用Paperclip将文件上传到S3时,S3中的远程路径会继承我的本地文件夹结构。
http://s3.amazonaws.com/example_com_bucket/Users/Jeff/Sites/example.com/web/public/assets/uploads/my_class/8/medium/some_image.png?1383060287
Why is this happening? 为什么会这样呢? How do I strip that part out?
我如何去除那部分? I tried changing the
:path
property but that only seemed to affect the "application" part of the path (eg after /assets/uploads
) My site is still in development, so I don't care about having to preserve links. 我尝试更改
:path
属性,但这似乎只影响:path
的“应用程序”部分(例如/assets/uploads
)我的站点仍在开发中,因此我不必担心必须保留链接。
My config is... 我的配置是...
config.paperclip_defaults = {
:storage => :s3,
:path => '/:class/:attachment/:id_partition/:style/:filename',
:s3_credentials => {
:bucket => 'example_com_bucket',
:access_key_id => '...',
:secret_access_key => '...'
}
}
I had this exact same issue when I was using the :url
parameter where I should have been using the :path
parameter: 当我使用
:url
参数时,我本应该使用:path
参数,也遇到了同样的问题:
has_attached_file :primary_photo,
:styles => ...,
:storage => :s3,
:s3_host_name => 's3-us-west-2.amazonaws.com',
:s3_credentials => 'config/s3.yml',
:url => '/product/:attachment/:id/:style/:filename'
I fixed it by changing my config to this: 我通过将配置更改为此来修复它:
has_attached_file :primary_photo,
:styles => ...,
:storage => :s3,
:s3_host_name => 's3-us-west-2.amazonaws.com',
:s3_credentials => 'config/s3.yml',
:path => '/product/:attachment/:id/:style/:filename'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.