简体   繁体   中英

swfupload 406 not acceptable error

def create
@asset = Asset.new(params[:asset])

respond_to do |format|
  if params[:Filedata]
    @asset = Asset.new :swf_uploaded_data => params[:Filedata]
    @asset.user = current_user
    @asset.save!

    format.html { render :text => @asset.image.url(:thumb) }
    format.xml  { render :nothing => true }

  else
    if @asset.save
      flash[:notice] = 'Created'
      format.html { redirect_to(@asset) }
      format.xml  { render :xml => @asset, :status => :created, :location => @asset }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @asset.errors, :status => :unprocessable_entity }
    end
  end
end
end

I am creating an upload status bar with swfupload. At the end of the upload I get a 406 error.

Not necessarily your answer but I had the same problem with Plupload and it happens that the request format is nil. It might not be the best way but one could do the following:

request.format ||= :xml

in order to provide some default format in the method. Hope it can help others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM