Hi, I''ve got a REST API that accepts PUT/POST requests of image data. (Well, that''s the plan.) Here are the relevant lines: My client (using ImageMagick) application reads image data from a file and then coverts it''s data into a blob: image = Magick::Image::read(@custom_image.full_filename).first Obj.image_data = image.to_blob Obj.save The ''Obj.save'' initiates a REST request (PUT/POST)that contains the binary image data as a member of params My controller on the REST app can do this: data = params[:image_data] #=> data is now a String Here''s how I''m saving the image data to the file system: File.open(path, "wb") do |f| f.binmode f.write data f.close end And data is saved.......but the image is unreadable, (ImageMagick on the REST app doesn''t recognize the image as a properly formatted jpeg. My questions are these: 1. What is the best way to send/receive image data to a REST service? 2. Is there anything terribly wrong with the approach I''ve taken? Thanks for your help, EB -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Marston A. wrote:> I''m curious about this too, did you find any answers to your > question? Or do you just have to generate the image, save it > somewhere and send the URL back in the REST API request instead of the > blob? > > On Apr 24, 5:09 pm, Elliott Blatt <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Yes, I found a solution. I Base64 encoded the image data on the sending side and then Base64 unencoded on the other receiving side. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Elliott, Great, simple solution. How big are the images you''re sending over? Do you notice any performance penalties? I''m thinking of doing the same, though the images I have are fairly small ( < 75k). On Jul 13, 2:19 pm, Elliott Blatt <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Marston A. wrote: > > I''m curious about this too, did you find any answers to your > > question? Or do you just have to generate the image, save it > > somewhere and send the URL back in the REST API request instead of the > > blob? > > > On Apr 24, 5:09 pm, Elliott Blatt <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > Yes, I found a solution. I Base64 encoded the image data on the sending > side and then Base64 unencoded on the other receiving side. > > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Marston A. wrote:> Elliott, > > Great, simple solution. How big are the images you''re sending over? > Do you notice any performance penalties? I''m thinking of doing the > same, though the images I have are fairly small ( < 75k). > > On Jul 13, 2:19 pm, Elliott Blatt <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>The performance is acceptable so far, but I''ve been working locally, so, I don''t know how it behaves over the internet. -EB -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---