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:
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?
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; Forms in HTML documents)
spaces are encoded by + signs, so the server is doing the correct
thing by turning them into spaces.
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?
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.