I use paperclip to add a file to my model.
I want to use the new firefox 3.6 function, xhr.sendAsBinary , to send an ajax request file.
This is how I build my query:
var xhr = new XMLHttpRequest(); xhr.open("POST", "/photos?authenticity_token=" + token + "&photo[name]=" + img.name + "&photo[size]=" + img.size); xhr.overrideMimeType('text/plain; charset=x-user-defined-binary'); xhr.sendAsBinary(bin);
name and size are saved in my model without problems, but the file itself is not captured using paperclip.
my model
class Photo < ActiveRecord::Base has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>" } end
migration
def self.up add_column :photos, :photo_file_name, :string add_column :photos, :photo_content_type, :string add_column :photos, :photo_file_size, :integer add_column :photos, :photo_updated_at, :datetime end
and my controller
Any idea how to solve this problem?
thanks
javascript firefox ajax ruby-on-rails paperclip
denisjacquemin
source share