6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RailsでTwilioにaudioファイルを渡す場合の注意点

Last updated at Posted at 2014-06-17

タイトルの内容に引っかかったので、ここで共有します。

ファイルのタイプを指定します

ファイルを呼ぶときに、audioであることの指定(type: 'audio/mp3')をしていないと、アプリケーションエラーになりました。
この例ではhollo_twilios_urlでファイルを呼び出しています。

app/controllers/twilios_controller.rb
  def hello
    send_file "#{Rails.root}/public/audios/hello.mp3", filename: 'hello.mp3', disposition: :inline, type: 'audio/mp3'
  end
config/routes.rb
resources twilio do
  get hello, on: :collection
end
音声ファイルの場所
puclic
 |-audios
   |-hello.mp3

誰かの参考になれば幸いです。

参考

https://www.twilio.com/docs/api/twiml/play
http://stackoverflow.com/questions/2830223/ruby-on-rails-audio-mp3-content-header-download

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?