Created
December 14, 2015 21:34
-
-
Save rogsmith/7ead0421e70a0edc3906 to your computer and use it in GitHub Desktop.
Save RubyZip to Paperclip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buffer_string = Zip::OutputStream.write_buffer do |zos| | |
zos.put_next_entry("FILENAME") | |
zos.write FILE_DATA | |
end.string | |
file = StringIO.new(buffer_string) | |
file.class.class_eval { attr_accessor :original_filename, :content_type } | |
file.original_filename = "#{file_name}.zip" | |
file.content_type = "application/zip" | |
document = Document.new | |
document.attachment = file | |
document.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment