Created
November 21, 2012 13:04
-
-
Save gregfroese/4124753 to your computer and use it in GitHub Desktop.
Posting an image in RubyMotion using BubbleWrap and saving it in Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## RubyMotion | |
imageData = UIImage.UIImageJPEGRepresentation(@image_view.image, 1) | |
encodedData = [imageData].pack("m0") | |
data["image"] = encodedData | |
BW::HTTP.post("http://localhost:3000/upload}", {payload: data}) do |response| | |
if response.ok? | |
end | |
end | |
## Rails backend | |
if params["image"] | |
unpack = params["image"].unpack("m0") | |
File.open("/tmp/image.jpg", "w+b") do |f| | |
f.write(unpack.first) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for posting this. Just curious: when you submit this via RubyMotion to your server, is there an incredible lag time?