class Uppr::Video
Constants
- RESOLUTIONS
Public Instance Methods
delete_tmp_dir(new_file)
click to toggle source
# File lib/uppr/video.rb, line 28 def delete_tmp_dir(new_file) # make sure we don't delete other things accidentally by checking the name pattern if @cache_id_was.present? && @cache_id_was =~ /\A[\d]{8}\-[\d]{4}\-[\d]+\-[\d]{4}\z/ FileUtils.rm_rf(File.join(root, cache_dir, @cache_id_was)) end end
extension_white_list()
click to toggle source
Add a white list of extensions which are allowed to be uploaded. For images you might use something like this:
# File lib/uppr/video.rb, line 91 def extension_white_list %w(mp4 mov avi mkv 3gp mpg mpeg) end
full_filename(for_file)
click to toggle source
Calls superclass method
# File lib/uppr/video.rb, line 38 def full_filename(for_file) super.chomp(File.extname(super)) + '.mp4' end
remember_cache_id(new_file)
click to toggle source
store! nil's the cache_id after it finishes so we need to remember it for deletion
# File lib/uppr/video.rb, line 24 def remember_cache_id(new_file) @cache_id_was = cache_id end
store_dir()
click to toggle source
Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted:
# File lib/uppr/video.rb, line 16 def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end