2014-06-11 2 views
2

저는 Paperclip과 Carrierwave를 사용하여 이미지를 S3에 업로드하고 있습니다. 현재 특정 모델의 이미지가 버킷의 루트에있는 이름이없는 폴더에 업로드되고 있습니다. 업로드 한 폴더에 빈 이름이 없도록하려면 어떻게해야합니까? 여기에 내가 어딘가에 선을 따라 이러한 옵션을 다시 작성하는 것 spree를 사용하고 있음을 언급하는 것을 잊었다 종이 클립/Carrierwave 이니셜 편집Paperclip/Carrierwave : 이미지가 이름이없는 폴더에 업로드되는 것을 어떻게 방지합니까?

fog_credentials = { 
    :provider => "AWS", 
    :aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'], 
    :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'], 
} 

# Carrierwave 
config.storage = :fog 
config.fog_credentials = fog_credentials 
config.fog_directory = ENV['AWS_S3_BUCKET'] 
config.fog_public = true 

# Paperclip 
Paperclip::Attachment.default_options[:storage] = :fog 
Paperclip::Attachment.default_options[:fog_credentials] = fog_credentials 
Paperclip::Attachment.default_options[:fog_directory] = ENV['AWS_S3_BUCKET'] 
Paperclip::Attachment.default_options[:fog_host] = ENV['AWS_S3_ASSET_HOST'] 
Paperclip::Attachment.default_options[:url] = ":class/:id_partition/:attachment/:style/:filename" 
Paperclip::Attachment.default_options[:path] = ":url" 

** **

에서 관련 코드입니다.

나는 그 기본값 모두 슬래시 접두어 된이 명시 적으로

Spree::Image.attachment_definitions[:attachment][:url] = "spree/products/:id/:style/:basename.:extension" 
Spree::Image.attachment_definitions[:attachment][:path] = "spree/products/:id/:style/:basename.:extension" 

을 설정하여 URL 및 경로 옵션을 변경. 이 paperclip-aws gem에 따르면이 옵션 앞에 슬래시를 붙이면 버킷 루트에 이름이없는 폴더가 만들어집니다.

+0

당신은 두 가지 보석을 사용하고 있다고 언급합니다 - 특별한 이유가 있습니까? 나는'paperclip'을 사용하는 것에 충실합니다. –

답변

1

나는 어딘가에이 옵션을 다시 쓰려고하는 spree을 사용하고 있다는 사실을 잊어 버렸다.

나는 그 기본값 모두 슬래시 접두어 된이 명시 적으로

Spree::Image.attachment_definitions[:attachment][:url] = "spree/products/:id/:style/:basename.:extension" 
Spree::Image.attachment_definitions[:attachment][:path] = "spree/products/:id/:style/:basename.:extension" 

을 설정하여 URL 및 경로 옵션을 변경. 이 paperclip-aws gem에 따르면이 옵션 앞에 슬래시를 붙이면 버킷 루트에 이름이없는 폴더가 만들어집니다.

관련 문제