0
我有这个创建行动使用的docx宝石和msworddoc-提取宝石如何使用docx gem与amazon s3?
if @subject.save
if @subject.odoc.present?
@odoc_url = @subject.odoc.url
if File.extname(URI.parse(@odoc_url).path) == ".docx"
@subject.homework= ""
doc = Docx::Document.open(@odoc_url)
doc.paragraphs.each do |p|
@subject.homework = @subject.homework+p.to_html
end
else
MSWordDoc::Extractor.load(@odoc_url) do |doc|
@subject.homework= doc.whole_contents
end
end
@subject.save
end
现在来提取doc和docx文件数据,DOC文件工作得很好。我的问题是与doc = Docx::Document.open(@odoc_url)
当我使用的代码在我的本地机器上它工作正常..当我推入产品我得到一个错误Zip::Error: File s3.amazonaws.com/~~~ not found
我真的不知道如何加载文件可访问的DOCX宝石
您最有可能将文件存储在dev中的文件系统中,而在生产中,则将其存储在S3中。首先下载文件(尝试http://stackoverflow.com/questions/30179444/download-file-from-s3-to-rails-4-app),然后将其保存在本地,然后继续阅读它。 – jvnill
我必须下载它吗?我的意思是msworddoc提取工作正常,无需下载文件 –