Usando Fog para examinar baldes S3

connection = Fog::Storage.new({ :provider => ‘AWS’, :aws_access_key_id => ‘my_key_id’, :aws_secret_access_key => ‘secret_key’, :region => ‘eu-west-1’}) # get the bucket s3_bucket_name = ‘my_bucket’ dir = connection.directories.detect { | dir | dir.key …

Continuar lendo

Nomes de arquivos personalizados com Carrierwave e Amazon S3

Com o seguinte uploader app/uploaders/document_uploader.rb: class DocumentUploader < CarrierWave::Uploader::Base storage :fog def store_dir “uploads/#{Rails.env}/#{model.class.to_s.underscore.pluralize}/#{mounted_as}/#{model.id}” end end def store_path(for_file = filename) “uploads/#{Rails.env}/#{model.class.to_s.underscore.pluralize}/#{mounted_as}/#{model.id}/#{for_file}” end def filename(uploaded_file = file) if uploaded_file.present? “Document with …

Continuar lendo