Hi! I''m developing a Rails-app that needs to take images from a separate program. I managed to upload base64 encoded images via HTTP-Post- Request (Cocoa), the HTTP-Body looks like (base64-data is shortened) this: "filename=Pic1.jpg&content_type=image/jpeg&data=/9j/4AAQSkZJRgABAQECeUJ +woRAD/4gxYSU" When I access the data via params[:data] in my controller, all the plus signs are gone and substituted with spaces. I checked the outgoing data of the separate program with a sniffer and it contains the plus signs, so the substitution must take place somewhere on the server. Does anybody have an idea what causes this behaviour? Thanks, Thomas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Jan-23 00:24 UTC
Re: Upload via API leads to missing plus signs in HTTP-Body
On Jan 22, 11:00 pm, TKAB <tbil...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi! > > I''m developing a Rails-app that needs to take images from a separate > program. I managed to upload base64 encoded images via HTTP-Post- > Request (Cocoa), the HTTP-Body looks like (base64-data is shortened) > this: > > "filename=Pic1.jpg&content_type=image/jpeg&data=/9j/4AAQSkZJRgABAQECeUJ > +woRAD/4gxYSU" > > When I access the data via params[:data] in my controller, all the > plus signs are gone and substituted with spaces. I checked the > outgoing data of the separate program with a sniffer and it contains > the plus signs, so the substitution must take place somewhere on the > server.The standards dictate that with application/x-www-form-urlencoded data (the default; http://www.w3.org/TR/html401/interact/forms.html#h-17.13.3.3) spaces are encoded by + signs, so the server is doing the correct thing by turning them into spaces. Fred --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you very much, I was completely unaware of that. So it would be a better idea to imitate a form upload and set the Content-Type to multipart/form-data? Or is there any other way?> The standards dictate that with application/x-www-form-urlencoded > data (the default;http://www.w3.org/TR/html401/interact/forms.html#h-17.13.3.3) > spaces are encoded by + signs, so the server is doing the correct > thing by turning them into spaces. > > Fred--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Jan-23 11:59 UTC
Re: Upload via API leads to missing plus signs in HTTP-Body
On 23 Jan 2009, at 08:18, TKAB wrote:> > Thank you very much, I was completely unaware of that. > So it would be a better idea to imitate a form upload and set the > Content-Type to multipart/form-data?Certainly an option> Or is there any other way? >You could replace + signs with what ever the correct % escape sequence is, but the multipart/form-data route is probably simpler. Fred> >> The standards dictate that with application/x-www-form-urlencoded >> data (the default;http://www.w3.org/TR/html401/interact/forms.html#h-17.13.3.3) >> spaces are encoded by + signs, so the server is doing the correct >> thing by turning them into spaces. >> >> Fred > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
OK, I understand. Thanks for your help! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Robert Walker
2009-Jan-23 21:47 UTC
Re: Upload via API leads to missing plus signs in HTTP-Body
TKAB wrote:> OK, I understand. > > Thanks for your help!http://en.wikipedia.org/wiki/Base64#URL_applications This might help. See the section on an alternative base64 that is safe for URL encoding. -- 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 -~----------~----~----~----~------~----~------~--~---