Andre Cubeta
2011-Jan-14 09:28 UTC
How to convert BinaryString to save in ImageFile at public path
Hello I need your help and expertise, I have a method_name called avatar which will pull data to the web and shows the photo object from the Binary String. def avatar @ja = Model.where("id" => params[:id]).limit(1).first if @ja.avatar && @ja.avatar.photo_binary send_data @ja.avatar.photo_binary, :type => @ja.avatar.content_type, :disposition => ''inline'' else path = "#{Rails.root}/public/images/default_avatar.png" send_file path, :type => "images/png", :disposition => ''inline'' end end in my show action page i load the image correctly = image_tag avatar_job_job_application_path(@job, @job_application), :class => "avatar" #This will show the photo but the url will absolutely show like /JDXXXXX/ja/JPXXXXX/avatar because it was parse by the avatar method Now, at the same time I want the show action to save the BinaryString to the filesystem as an image file. Life for example XXXX.jpg inside so that I can call the file direcltly Now it is a BinaryString that I want to save it temporarily in the #{Rails.root}/public/assets/XXX.jpg How can I do that? Any suggestions guys? Thanks! Andre -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.