ruby on rails - Paperclip processor not changing file contents -


I am trying to change the lines of an uploaded text file attachment using the paperclip processor in Rail. I can verify with a debugger that my processor is called, but the file attached is my original file, not a file written by the processor. Here's my processor:

  Module paperclip class Utf8 & lt; Processor def start (file, option = {}, attachment = nil) super @ file = file @ attachment = attachment @ servantmat = file. IDName (@file.pass) @format = options [: format] @ BSName = file BSN (@ File.path, @current_format) make the end DEF @ file.rewind tmp = Tempfile.new ([@ basename, @format]) IO.foreach (@ file.path) do | Line | TMP & lt; & Lt; Line.encode ('UTF-8', 'binary', invalid :: substituted, undo: replace, replace: '') end end of tmp.flush tmp end  

And here's my model:

  Category list & lt; ActiveRecord :: Base has_attached_file: file, storage :: s3, s3_credentials: Rails.root.join ('config', 'aws.yml'), bucket: Rails.application.config.s3_bucket, Processor: [: utf8], style : {Utf8: {format: 'txt}}}  

Any thoughts that I am doing wrong? As I think, the file has been returned from the make, which adds the model to the paperclip. What can be anything from this?

found a solution: the paperclap separates each style from the file. To overwrite the original file instead of creating a new one, I had to change my model to:

  Category list & lt; ActiveRecord :: Base has_attached_file: file, storage :: s3, s3_credentials: Rails.root.join ('config', 'aws.yml'), bucket: Rails.application.config.s3_bucket, Processor: [: utf8], style : {Original: {Specifying original style can be overwritten by default file format: 'txt'}} End  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -