I store my files in a document table
with paperclip
.My files are word,csv,xlsx
and pdf
.
I want to read these records from database and convert them into cdata
and put them in an xml tag named Attachment
.
This is the out put I'm looking forward:
<Attachment ContentType="xlsx" Extension="xlsx" Description="TEST2.xlsx"><![CDATA[UEsDBBQABgAIAAAAIQBxDjkrcAEAAKAFAAATANsBW0NvbnRlbnRfVHlwZXNdLnhtbCCi1wEooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA..
and my files are like this when I query them:
#<Paperclip::Attachment:0x000000049dfe28 @name=:picture, @name_string="picture", @instance=#<Document id: 225, picture_file_name: "data", picture_content_type: "application/vnd.openxmlformats-officedocument.word...", picture_file_size: 10001, picture_updated_at: "2018-02-07 20:14:18", ece_id: 242, created_at: "2018-02-07 20:14:18", updated_at: "2018-02-07 20:14:18", xml_file_name: nil, xml_content_type: nil, xml_file_size: nil, xml_updated_at: nil, whodunnit: nil, document_type: "Attachment">, @options={:convert_options=>{}, :default_style=>:original, :default_url=>"/:attachment/:style/missing.png", :escape_url=>true, :restricted_characters=>/[&$+,\/:;=?@<>\[\]\{\}\|\\\^~%# ]/, :filename_cleaner=>nil, :hash_data=>":class/:attachment/:id/:style/:updated_at", :hash_digest=>"SHA1", :interpolator=>Paperclip::Interpolations, :only_process=>[], :path=>":rails_root/public:url", :preserve_files=>false, :processors=>[:thumbnail], :source_file_options=>{}, :storage=>:filesystem, :styles=>{}, :url=>"/system/:class/:attachment/:id_partition/:style/:filename", :url_generator=>Paperclip::UrlGenerator, :use_default_time_zone=>true, :use_timestamp=>true, :whiny=>true, :validate_media_type=>true, :check_validity_before_processing=>true}, @post_processing=true, @queued_for_delete=[], @queued_for_write={}, @errors={}, @dirty=false, @interpolator=Paperclip::Interpolations, @url_generator=#<Paperclip::UrlGenerator:0x000000049dfd10 @attachment=#<Paperclip::Attachment:0x000000049dfe28 ...>>, @source_file_options={}, @whiny=true>
I'm using nokogiri
to generate the xml tags.
Do you have any ideas? Thanks in advance