我有一个问题,我正在使用 Listen gem 来跟踪添加的新文件的文件夹,添加一个新文件后,我想用 Shrine 将它复制到另一个存储,但是 Listen gem 在“添加”变量中返回我添加的路径文件,但是 Shrine 需要一个对象才能正确运行,如果我有该文件的路径,我如何获取对象?有人能帮我吗?
load './config/initializers/shrine.rb'
module FileTracker
file_dir = "./public/uploads/cache"
listener = Listen.to(file_dir) do |modified, added, removed|
puts "modified absolute path: #{modified}"
puts "added absolute path: #{added}"
puts "removed absolute path: #{removed}"
FileUtils.cp_r added, './public/uploads/store' # this code is copy files, but i need do it with Shrine
#added.each { |file| p Shrine.new(:store).path(file) } #this code is return error
end
listener.start
sleep
end