问题描述
我用回形针与轨道4的应用程序和Amazon S3存储。在我的机器,该网站是在
运行 /Users/Jeff/Sites/example.com/web
当我上传与回形针S3的文件,在S3中的远程路径会继承我的本地文件夹结构。
<$p$p><$c$c>http://s3.amazonaws.com/example_com_bucket/Users/Jeff/Sites/example.com/web/public/assets/uploads/my_class/8/medium/some_image.png?1383060287这是怎么回事?我如何剥离的那部分?我试图改变:路径
属性,但只似乎影响路径的应用程序的一部分(例如,当 /资产/上传
)我的网站仍然在发展,所以我不在乎不必preserve链接。
我的配置是...
config.paperclip_defaults = {
:存储=&GT; :S3,
:PATH =&GT; /:类/:附件/:id_partition /:款式/:文件名',
:s3_credentials =&GT; {
:斗=&GT; example_com_bucket,
:access_key_id =&GT; '...',
:secret_access_key =&GT; '...'
}
}
我有,当我用的是此相同的问题:网址
参数,我应该使用过在:路径
参数:
has_attached_file:primary_photo,
:风格=&GT; ...,
:存储=&GT; :S3,
:s3_host_name =&GT; s3-us-west-2.amazonaws.com,
:s3_credentials =&GT; 配置/ s3.yml',
:URL =&GT; '/产品/:附件/:ID /:款式/:文件名
我固定它通过改变我的配置,以这样的:
has_attached_file:primary_photo,
:风格=&GT; ...,
:存储=&GT; :S3,
:s3_host_name =&GT; s3-us-west-2.amazonaws.com,
:s3_credentials =&GT; 配置/ s3.yml',
:PATH =&GT; '/产品/:附件/:ID /:款式/:文件名
I'm using Paperclip with a Rails 4 app and Amazon S3 storage. 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.
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 (e.g. after /assets/uploads
) My site is still in development, so I don't care about having to preserve links.
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:
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'
这篇关于回形针+ AWS S3,prefixing远程路径与我的本地路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!