I have this create action to extract data from doc and docx files using the docx gem and the msworddoc-extractor gem
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
now, doc files works fine.. My problem is with doc = Docx::Document.open(@odoc_url) when i use the code on my local machine it works fine.. when i push into production i get an error Zip::Error: File s3.amazonaws.com/~~~ not found I'm not really sure how to load the file to be accessible to the docx gem
So i finally got it without having to download the file using open-uri
doc = Docx::Document.open(open(@odoc_url).path)