Wrong MIME type for mp3 subjects
Closed this issue · 4 comments
srallen commented
Related to zooniverse/Panotpes#2458, @trouille reports
When I try with the Panoptes Python Client and the script at this link, I get the error:
panoptes_client.panoptes.PanoptesAPIException: Validation failed: Locations is invalid
Rails does not recognize audio/mp3
as a valid MIME type. For mp3s, the MIME type needs to be audio/mpeg
. magic
is likely detecting the wrong MIME type for these files.
srallen commented
magic
appears to be detecting mp3s as audio/x-wav
adammcmaster commented
I'm not able to reproduce this here.
>>> f = open('/Users/adam/Desktop/file.mp3', 'rb')
>>> magic.from_buffer(f.read(), mime=True)
'audio/mpeg'
>>> f.close()
>>> from panoptes_client import Panoptes, Project, Subject
>>> Panoptes.connect([...])
<panoptes_client.panoptes.Panoptes object at 0x7f4187443208>
>>> p = Project(7)
>>> s = Subject()
>>> s.links.project=p
>>> s.add_location('/Users/adam/Desktop/file.mp3')
>>> s.save()
>>>
eatyourgreens commented
From memory, the issue was the specific files that were being uploaded. The extension was .mp3, but they were actually WAV files.
adammcmaster commented
Ah ok, in that case I'll close this.