diaspora/app/uploaders/secure_uploader.rb
Benjamin Neff 541da9f682
Bump carrierwave
Carrierwave 3.0.4 cleans the original_filename after store, but we can
still get the original filename from the file directly.
2024-06-05 00:33:58 +02:00

14 lines
408 B
Ruby

# frozen_string_literal: true
class SecureUploader < CarrierWave::Uploader::Base
protected
def extension
".#{file.filename.split('.').drop(1).join('.')}" if file.present? && file.respond_to?(:filename)
end
def secure_token(bytes=16)
var = :"@#{mounted_as}_secure_token"
model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.urlsafe_base64(bytes))
end
end