Ruby on the Rails: Paperclip and Rubies Mp3Info

I try to download an MP3 file (using the paperclip plugin) and then immediately read the MP3 information (using Mp3 Mp3) to get the title, song length, etc.

I can successfully download the MP3 file using paperclip, but when I try Mp3Info.open (@ song.music.url), I get an error when the file is empty. Is there a correct file link so that Mp3Info can find the file?

(Note that the actual file is located 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 %>
+3
source share
2 answers

try the "path" method instead of "url"

@song.music.path
+7
source

. @song.music.path!

: URL- , Mp3Info .

0

Source: https://habr.com/ru/post/1716976/


All Articles