I need to write a web service that accepts file uploads (even large  
ones). My WS is REST based, so I have a create method that accepts  
only POST.
My problem is passing the file to the method, so if someone already  
solved this problem please let me know.
For example, do I need to use Base64 encoding, and decode inside ?
My method is like this:
  def create
    radio = Radio.create!( params[ :radio ] )
    ad = Ad.new( params[ :ad ].merge( :user => current_user, :resource  
=> radio ) )
    ad.save!
    respond_to do |format|
      format.html
      format.xml { render :xml => ad.to_xml, :status => :created }
    end
  rescue ActiveRecord::RecordInvalid
    respond_to do |format|
      format.html { render :action => :new }
      format.xml { render :xml => "<errors> <error>
#{e.message} </
error> </errors>", :status => :unprocessable_entity }
    end
  end
My concern is about what gets saved inside the Radio object, I don''t  
think I can pass a raw binary object (AFAIK).
Also, about rspeccing the whole thing, I think I need to write  
controller tests that check that the file I begin with is exactly the  
same I have after using the WS, but isn''t it something I
shouldn''t do
in RSpec ? I mean, using real data. In this case I can have the  
controller behaving exactly as I think it should by calling the right  
methods in the right way, but having a corrupted file in the fs .... I  
can''t test data in the model either, because corruption will happen  
exactly inside the controller.
I''m new to this stuff, so I''m pretty clueless. Every help is
very
appreciated.
TIA,
  ngw
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---