I have been struggling with this problem for more than a week!
I'm having trouble sending images from my iphone to the backend rails server with carrier configuration settings. Posting through a web form works very well, although publishing text from iphone via JSON also works.
Here is my photo controller:
class PhotosController < ApplicationController def new @photo = Photo.new(:user_id => params[:user_id]) end def create @photo = current_user.photos.build(params[:photo]) if @photo.save respond_to do |format| format.html { flash[:notice] = "Successfully created photo." redirect_to @photo.user } format.json { render :json => {:action => 'create', :owner => current_user} } end else render :action => 'new' end end
and here is the objective-c code:
UIImage *image = [UIImage imageNamed:@"moon.png"]; NSData *imageData = UIImagePNGRepresentation(image); NSString *urlString=[NSString stringWithFormat:@"http://127.0.0.1:3000/photos.json"];
The answer I get from the server:
"EOFError (body of bad content)"
objective-c code was tested on the php server and the download was successful! so I think my problem is with my rails / carrierwave setting. please help me get bloody images from my iPhone and my rails server.
Your help is greatly appreciated.
source share