从 Carrierwave 迁移到 Shrine 后,一些测试开始失败。我注意到,#read
从安装 Shrine 上传器的列调用时,它只能调用一次。通过做一秒钟#read
将返回一个空字符串。也许我缺少一些配置,但相同的代码适用于 Carrierwave(我知道它是一个不同的上传器,但对于我正在经历的迁移到 Shrine 的代码库需要很少/几乎不需要更改)
# shrine.rb -> for testing
require "shrine"
require "shrine/storage/s3"
require "shrine/storage/file_system"
Shrine.plugin :activerecord
Shrine.plugin :cached_attachment_data
Shrine.plugin :determine_mime_type, analyzer: :mime_types
Shrine.storages = {
cache: Shrine::Storage::FileSystem.new(
"public",
prefix: "tmp/cache",
),
store: Shrine::Storage::FileSystem.new(
"public",
prefix: "tmp",
),
}
# carrierwave.rb -> for testing
...
config.storage = :file
config.enable_processing = false