1

I'm trying to upload a file to my controller via an api call from another app. I'm using Faraday to make the post request but I'm getting this error:

Paperclip::AdapterRegistry::NoHandlerError (No handler found for "#<UploadIO:0x007fb3ba8391c0>"):
app/controllers/talks_controller.rb:21:in `create'

This is my faraday request:

puts conn.post "/talks.json", { talk: { title: 'asdf8', link: 'fakelink', audio: Faraday::UploadIO.new('dhh-37signals.mp3', 'audio/mp3') }}

And this is my model:

class Talk < ActiveRecord::Base
  validates :title, presence: true,
                length: { minimum: 5 }
  validates :link, presence: true
  has_attached_file :audio
  do_not_validate_attachment_file_type :audio
end

I think it has something to do with paperclip only seeing this #<UploadIO:0x007fb3ba8391c0>" as my uploaded file and not my actual file. When I upload a file through my form in my view it works fine, but uploading through Faraday isn't working. Any ideas?

Blake Erickson
  • 755
  • 1
  • 9
  • 28

0 Answers0