我需要帮助弄清楚如何让CarrierWave与ActiveResource对象一起工作。我正在开发一个目前在标准ActiveRecord对象上使用CarrierWave的项目,该对象非常好用。但是,我们正在迁移到远程文件系统,因此我需要CarrierWave来处理ActiveResource对象。
我知道CarrierWave允许你编写自己的存储引擎,而不是使用say fog,file或mongo grid_fs,但我无法弄清楚这个过程的流程是什么。
以下是我的努力状况:
ReportDocument类
class ReportDocument
mount_uploader :merchant_geoip_image, ImageUploader
end
CarrierWave上传器
class ImageUploader < CarrierWave::Uploader::Base
storage MyCustomStorageEngine
end
我的自定义存储引擎
class MyCustomStorageEngine
def store!(file)
# do custom storage stuff with ActiveResource object here
end
def retrieve!(identifier)
# do custom retrieval stuff with ActiveResource object here
end
end
我的问题是,当我保存store!
对象时,我无法让CarrierWave调用我的自定义retrieve!
和ReportDocument
方法。 Mongoid ORM将其存储引擎定义为gridFS
,可在此处找到:https://github.com/carrierwaveuploader/carrierwave-mongoid/blob/master/lib/carrierwave/storage/grid_fs.rb
我似乎没有做过与Mongoid ORM实现不同的任何事情。任何帮助将不胜感激。