I am uploading an audiofile and make a mp3 version, which works. Additionally I am generating a waveform out of the mp3 as a "png". Wich also works well.
The image was generated and saved but with "mp3" as suffix, which should be "png". The view has rendered the image correctly with the "mp3" fileextension name.
Now I get a 404 error when the view tries to get the image. The filename was not assumed correctly:
https://mybucket.amazonaws.com/uploads/sound/soundfile/142/waveform_Sky_02.wav
which should be
https://mybucket.amazonaws.com/uploads/sound/soundfile/142/waveform.png
here is my :version code:
version :waveform do
def filename
"watermark.png" if original_filename.present?
end
def convert_to_waveform
cache_stored_file! if !cached?
Dir::Tmpname.create(File.basename(current_path)) do |tempname|
begin
puts system %Q{ffmpeg -y -i "#{current_path}" -f wav "#{tempname}" > /dev/null 2>&1}
FileUtils.rm current_path
Waveform.generate(tempname, current_path, method: :rms, background_color: :transparent)
ensure
FileUtils.rm tempname
end
end
end
process :convert_to_waveform
end
The database saves "waveform_Sky_02.wav"
How can I get this working?
this has been working for me:
def full_filename(for_file=file)
super.chomp('wav') + '.png'
end
or for all filetypes:
def full_filename(for_file=file)
super.chomp(File.extname(super)) + '.png'
end