尝试传递图像时出现此错误:
!! Unexpected error while processing request: invalid byte sequence in UTF-8
奇怪的是,加注(如下)没有被执行。
我的问题是:这怎么会导致这个错误?它与标题或参数有什么关系吗?
这里的任何帮助将不胜感激。
def create
raise "request did get executed in code here"
debugger
@asset = nil
if params && params[:asset]
p = params[:asset]
if p[:file]
user_id = p[:user_id] || current_user.try(:id)
checksum = p[:checksum] || Util.file_checksum(p[:file].path)
if user_id.present? && checksum.present?
options = {:taken_at => p[:taken_at] || Util.file_taken_at(p[:file].path)}
@asset = Asset.create user_id, checksum, p[:file], p[:file].original_filename, options
end
end
end
respond_to do |format|
if @asset && @asset.state != QueueItem::STATE_NONE
format.html { head :no_content }
format.json { render :json => @asset, :status => :created }
else
format.html { head :no_content }
format.json { render :json => @asset.try(:errors), :status => :unprocessable_entity }
end
end
end