Help re-write this Python into Ruby: AJAX POST, decode Base-64, and save
I'm following a phonegap tutorial and I do not know how to write this "def iphone_uplo开发者_如何学编程ad " action in ruby 1.9.2/rails 3.
http://wiki.phonegap.com/w/page/18270855/Image-Upload-using-JQuery-and-Python
function getPicture_Success(imageData)
{
var feedURL = APIPATH + "photos/iphone-upload/";
$.post(feedURL, {imageData:imageData}, function(data){
});
}
In Python (Django):
def iphone_upload(request):
import base64
data = base64.b64decode(request.POST.get("imageData"))
fileout = "/var/www/test.jpg"
f1 = open(fileout,'wb+')
f1.write(data)
f1.close()
def iphone_upload
@data = request.POST[:imageData].unpack("m")[0]
fileout = "/var/www/test.jpg"
File.open(fileout, 'w') {|f| f.write(@data) }
end
精彩评论