Paperclip attachment content_type validation fails only in Safari

I have a model with a Paperclip attachment which should only accept some audio formats. The model is as follows:

class SoundOutput < ActiveRecord::Base
  has_attached_file :audio
  validates_attachment :audio,
    content_type: { content_type: ['audio/x-wav', 'audio/wav', 'audio/mp3', 'audio/x-mp3'] }
end

I can upload my .mp3 files in Google Chrome. But the exact same files don't pass the validation when I submit them from Safari. I get 2 error messages:

['Audio content type is invalid', 'Audio is invalid']

Relevant info from my Gemfile:

ruby '2.2.3'

gem 'rails', '4.2.5.1'
gem 'paperclip', '~> 4.3'

Upvotes: 0

Views: 188

Answers (1)

Tony Vincent
Tony Vincent

Reputation: 14262

Try adding audio/mpeg, audio/x-mpeg content types to the validation.

Upvotes: 1

Related Questions