Tag: fog

加载到Heroku时Carrierwave / fog / AWS问题“无法加载此类文件 – 雾”

所以我是一个新手,并通过Michael Hartl的rails教程。 在尝试使用carrierwave,fog-aws为S3 AWS配置图片上传时,我变得完全陷入困境。 当推送到heroku时,我收到以下错误: LoadError:无法加载此类文件 – 雾 作为旁注,我尝试在开发模式中使用完全相同的代码,rails服务器工作正常,我能够成功上传文件到AWS。 因此,这不是AWS的配置设置问题。 尝试将应用程序推送到Heroku时出现问题。 这是我的设置: gemfile source ‘https://rubygems.org’ gem ‘rails’, ‘5.1.4’ gem ‘bcrypt’, git: ‘https://github.com/codahale/bcrypt-ruby.git’, :require => ‘bcrypt’ gem ‘faker’, ‘1.7.3’ gem ‘carrierwave’, ‘1.0.0’ gem ‘fog-aws’, ‘2.0.0’ gem ‘mini_magick’, ‘4.7.0’ gem ‘nokogiri’, ‘1.8.1’ gem ‘will_paginate’, ‘3.1.6’ gem ‘bootstrap-will_paginate’, ‘1.0.0’ gem ‘bootstrap-sass’, ‘3.3.7’ gem ‘puma’, ‘3.9.1’ gem ‘sass-rails’, ‘5.0.6’ […]

需要更改S3 Bucket(Carrierwave / Fog)中文件的存储“目录”

我正在使用带有3个独立模型的Carrierwave将照片上传到S3。 我保留了上传器的默认设置,即将照片存储在根S3存储桶中。 然后我决定根据模型名称将它们存储在子目录中,例如/ avatars,items /等等,根据它们从上传的模型… 然后,我注意到同名文件被覆盖,当我删除模型记录时,照片没有被删除。 我已经从上传者特定的设置更改了store_dir,如下所示: def store_dir “items” end 在模型ID下存储照片的通用版(我使用mongo FYI): def store_dir “uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}” end 这就是问题所在。 我试图将已经进入S3的所有照片移动到S3中的正确“目录”中。 从我准备好的,S3本身没有目录。 我在使用rake任务时遇到了麻烦。 由于我更改了store_dir,因此Carrierwave正在查找之前上传到错误目录中的所有照片。 namespace :pics do desc “Fix directory location of pictures on s3” task :item_update => :environment do connection = Fog::Storage.new({ :provider => ‘AWS’, :aws_access_key_id => ‘XXXX’, :aws_secret_access_key => ‘XXX’ }) directory = connection.directories.get(“myapp-uploads-dev”) Recipe.all.each […]

301 S3上传后永久移动

我试图使用carrierwave和雾gem将图像上传到Ruby on Rails上的S3,正确上传图像但是当我尝试保存包含刚刚上传的图像信息的模型时我得到了这个错误: Excon::Errors::MovedPermanently in UserController#show app/models/user.rb:46:in `process_image_with_key’ app/controllers/user_controller.rb:12:in `show’ <Excon::Response:0x007f97846a3c18 @body="\nPermanentRedirectThe bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. 用户模型: mount_uploader :image, AvatarUploader def image_name File.basename(image.path || image.filename) if image end def process_image_with_key( key ) unless key.nil? self.key = key self.remote_image_url […]