Created
August 3, 2014 15:45
-
-
Save emirikol/c6942401148a05c7ef18 to your computer and use it in GitHub Desktop.
saving paperclip string directly
This file contains 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
#option A) | |
stream = StringIO(string) | |
stream.content_type = 'application/pdf' #paperclip adds silly attr accessors to StringIO that we need to pass validations | |
#stream.original_filename = "anything.pdf" #if needed... | |
signed_pdf_document.original_pdf = stream | |
signed_pdf_document.save | |
#option B) | |
file = Tempfile.new( ["file_name", '.pdf'] ) | |
file.write( string ) | |
signed_pdf_document.attachment = file | |
signed_pdf_document.save | |
#will probably work: | |
signed_pdf = business.sign_document(pdf_string) | |
stream = StringIO.new | |
signed_pdf.write(stream) | |
stream.content_type = 'application/pdf' | |
signed_pdf_document.original_pdf = stream | |
signed_pdf_document.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment