views:

418

answers:

2

I'm trying to upload a mp3 file (using the paperclip plugin) and then read the mp3 info (using the Mp3Info gem) right away so I can get the title, song length ect.

I can successfully upload a mp3 file using paperclip, but when I try Mp3Info.open(@song.music.url), I get an error saying the file is empty. Is there a proper reference to a file so that the Mp3Info can find the file?

(Note the actual file sits in /public/system/musics/:id/original/:filename.extention)

ActionView::TemplateError (empty file) on line #5 of app/views/songs/_upload.erb:

5: <%  Mp3Info.open( @song.music.url ) do |mp3|  %>
6:  <% mp3.tag.title %>
7: <% end %>
+5  A: 

try the "path" method instead of "url"

@song.music.path
astropanic
A: 

atropanic is right. Use @song.music.path!

Here is why: The URL is useless in this context, because Mp3Info expects a local file.

Christoph Schiessl