Error Empty file upload result - problem with jQuery bulk file upload

116 views
Skip to first unread message

Bigos

unread,
Mar 28, 2013, 3:03:48 PM3/28/13
to rubyonra...@googlegroups.com

I have problems with multiple file upload. I tried Paperclip with jQuery file uplad plugin and get the error mentioned in the title. Files get uploaded without problems, but I keep getting this embarrassing error.

Can somebody offer a solution to my problem or suggest alternative solution that can be implemented in 2 hours? My client is getting a bit uneasy now.

I have tried everything I could think of and in the end I have modified the model following this advice:
https://github.com/blueimp/jQuery-File-Upload/issues/365#issuecomment-13859210

My code can be found at:
https://github.com/bigos/chrisb-images/blob/master/app/models/upload.rb

relevant bit in my model looks like this:

  def to_jq_upload
    {
      :files => [
                 {
                   :name => upload_file_name,
                   :type => upload_content_type,
                   :size => upload_file_size,
                   :url => upload.url,
                   :delete_url => upload_path(self),
                   :delete_type => "DELETE"
                 }
                ]
    }
  end

Bigos

unread,
Mar 29, 2013, 5:46:38 AM3/29/13
to rubyonra...@googlegroups.com


On Thursday, 28 March 2013 19:03:48 UTC, Bigos wrote:

I have problems with multiple file upload. I tried Paperclip with jQuery file uplad plugin and get the error mentioned in the title. Files get uploaded without problems, but I keep getting this embarrassing error...

Fixed!!!
controller:
https://github.com/bigos/chrisb-images/blob/master/app/controllers/photos_controller.rb

  def create
    @photo = Photo.new(params[:photo])

    respond_to do |format|
      if @photo.save
        format.html { render :json => [@photo.to_jq_upload].to_json,
          :content_type => 'text/html',
          :layout => false
        }
        format.json { render json: {files: [@photo.to_jq_upload] }}
      else
        format.html { render action: "new" }
        format.json { render json: @photo.errors, status: :unprocessable_entity }
      end
    end
  end




model:
https://github.com/bigos/chrisb-images/blob/master/app/models/photo.rb
Reply all
Reply to author
Forward
0 new messages