You can try with the example in the attachment_fu home (http:// github.com/technoweenie/attachment_fu/tree/master):
i.uploaded_data = ActionController::TestUploadedFile.new(file_path, mimetype) Regards. Franco Catena. On Jun 1, 6:23 am, holden <[email protected]> wrote: > I tried using ActionController::UploadedStringIO.new( data ) > > and it does create the files... but the images don't work. > > Is data supposed to be the filepath? ie. photos/joe.jpg ? > > I also found an example of exactly what I want to do in the Practical > Rails Plugins book, but which is outdated using "temp_data =" It > looks simple and perfect, what am I missing? > > http://books.google.com/books?id=c1L4IzmUzicC&pg=PA49&lpg=PA49&dq=att... > > On May 31, 11:22 pm, Maurício Linhares <[email protected]> > wrote: > > > Here's how I'm doing it: > > > file = ActionController::UploadedStringIO.new( data ) #this is > > the real data > > file.instance_variable_set( '@original_filename', > > "#{rand(1000)}_#{filename}" ) > > file.content_type = i.content_type > > > i.uploaded_data=( file ) > > i.save! > > > - > > Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br) > > |http://blog.codevader.com/(en) > > > On Sun, May 31, 2009 at 5:52 PM, holden <[email protected]> wrote: > > > > Something like this almost work... > > > > Discussion.new > > > (:name=>"test2", :location_id=>"1036", :image_attributes=> > > > [{ :uploaded_data=> File.new("/Users/holden/Desktop/pictures/ > > > LionsFW.jpg") }], :website=>"testdsfdf", :geo=>"", :phone=>"test", > > > :blurb=>"testdsfsdfsdf", :address=>"test", :hwID=>"test", > > > :email=>"[email protected]") > > > > undefined method `[]' for #<File:/Users/holden/Desktop/pictures/ > > > LionsFW.jpg > > > > On May 31, 6:36 pm, holden <[email protected]> wrote: > > >> I'm trying to use attachment fu to add a large number of images at > > >> once using a script but i can't even get it to add an image from the > > >> console... the other documentation i've found no longer seems to work. > > > >> Something like this doesn't work properly > > > >> c = Image.new > > >> c.content_type = 'image/jpeg' > > >> c.filename = 'test.jpg' > > >> c.discussion_id = 7330 > > >> c.uploaded_data = File.open('/Users/holden/Desktop/pictures/ > > >> LionsFW.jpg') > > >> c.save > > > >> It does save.. but the file doesn't get populated. > > > >> All the previous documentatio circa 2007 says :temp_file but this is > > >> no longer available to i tried switching it to :uploaded_data, but > > >> that doesn't seem to work either.... > > > >> also it want's the size and is a required field, but shouldn't this be > > >> automatically deduced.. providing it doesn't help either... > > > >> Any suggestions would be a great help, > > > >> Thanks, > > > >> holden --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

