Skip to content

Instantly share code, notes, and snippets.

@gregorynicholas
Forked from gregfroese/gist:4124753
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregorynicholas/68e345aa2a56859b8cf4 to your computer and use it in GitHub Desktop.
Save gregorynicholas/68e345aa2a56859b8cf4 to your computer and use it in GitHub Desktop.
## 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