weshatheleopard / rubyXL

Ruby lib for reading/writing/modifying .xlsx and .xlsm files
MIT License
1.27k stars 254 forks source link

Reading file from S3 fails to parse #249

Open krainboltgreene opened 7 years ago

krainboltgreene commented 7 years ago
Exception: Nokogiri::XML::SyntaxError: Document is empty
--
 0: /usr/local/bundle/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/document.rb:58:in `read_io'
 1: /usr/local/bundle/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/document.rb:58:in `parse'
 2: /usr/local/bundle/gems/nokogiri-1.6.8.1/lib/nokogiri/xml.rb:64:in `parse'
 3: /usr/local/bundle/gems/rubyXL-3.3.22/lib/rubyXL/objects/ooxml_object.rb:110:in `parse'
 4: /usr/local/bundle/gems/rubyXL-3.3.22/lib/rubyXL/objects/ooxml_object.rb:440:in `block in parse_file'
 5: /usr/local/bundle/gems/rubyzip-1.2.0/lib/zip/entry.rb:495:in `get_input_stream'
 6: /usr/local/bundle/gems/rubyXL-3.3.22/lib/rubyXL/objects/ooxml_object.rb:440:in `parse_file'
 7: /usr/local/bundle/gems/rubyXL-3.3.22/lib/rubyXL/objects/root.rb:65:in `parse_zip_file'
 8: (pry):47:in `block in __pry__'
 9: /usr/local/bundle/gems/rubyzip-1.2.0/lib/zip/file.rb:133:in `open_buffer'

I'm using parse_buffer on a string derived from S3 via the fog gem. The content type is "application/vnd.ms-excel". It works if the file is local.

dmferrari commented 7 years ago

Hey Kurtis, did you manage to solve this? I am having the same issue.

weshatheleopard commented 7 years ago

@dmferrari : can you provide a minimal test case please?

krainboltgreene commented 7 years ago

It was a bit ago. Either I wasn't actually pulling down a document or the document IO was incorrectly being thought of as empty. I think it was the latter.

I probably forced them to export XML files.

weshatheleopard commented 7 years ago

@krainboltgreene , @dmferrari : give me a minimal test case so I can reproduce the issue. (I have access to S3 so I can upload the file, but I don't have time right now to write the test case myself).