使用 CarrierWave 和 Amazon S3,我可以存储来自本地文件的图像,但是当我尝试从某个 url 存储它们时,我得到“TypeError: can't convert nil into String”
from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/carrierwave-0.5.8/lib/carrierwave/uploader/cache.rb:149:in `join'
from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/carrierwave-0.5.8/lib/carrierwave/uploader/cache.rb:149:in `cache_path'
from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/carrierwave-0.5.8/lib/carrierwave/uploader/cache.rb:121:in `block in cache!'
from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/carrierwave-0.5.8/lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks'
from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/carrierwave-0.5.8/lib/carrierwave/uploader/cache.rb:112:in `cache!'
from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/carrierwave-0.5.8/lib/carrierwave/uploader/store.rb:56:in `store!'
from (irb):5
from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands/console.rb:45:in `start'
from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands/console.rb:8:in `start'
from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
这是我正在尝试的代码
require 'open-uri'
image = "open(image_url)
@object.image.store!(file)
显然@object 保存了 Uploader 图像,并且使用本地文件系统运行良好。我试图添加一个
def root Rails.root.join 'public/' end
我的上传者也没有运气。
任何的想法?