我将此示例用于文件上传器。 保存文件后,我想用 R 分析它并将 r-plot 保存在数据库中。
那是我的upload.rb:
Paperclip::interpolates :array_type_folder do |attachment, style|
attachment.instance.upload_content_type
end
has_attached_file :upload,
:url =>"/system/Files/:array_type_folder/:basename.:extension",
:path =>":rails_root/public/system/Files/:array_type_folder/:basename.:extension"
after_save :do_picture_analyse
def do_picture_analyse
require 'rinruby'
myr = RinRuby.new(echo=false)
myr.fileurl=upload.url(:original)
puts "#{myr.fileurl}"
myr.eval <<EOF
s=read.table(fileurl)
jpeg(filename=':rails_root/public/system/Files/Pictures/probe.jpeg',width=250, height=250)
hist(s$V1)
dev.off()
EOF
end
由于这一行,我可以在数据库中看到文件的 url(仅供我测试)
myr.fileurl=upload.url(:original)
puts "#{myr.fileurl}"
当我上传文件probe2.cel并用R分析它时出现这种错误:
/system/Files/11/probe2.cel?1353680334 (that is the result of puts "#{myr.fileurl}")
Error in file(file, "rt") : could not open the connection
Error:
In file(file, "rt") :
'/system/Files/11/probe2.cel?1353680334' no such file or directory
Error in hist(s$V1) : Object 's' not found
它似乎无法连接到数据库并且找不到文件。我该如何处理?提前致谢