Sha256: 62e02c247f6111c0d321dd0be490f0830ded57c75e663c0e7b37bbb98f5d0167

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

# encoding: utf-8

class Phcpress::PstimageUploader < CarrierWave::Uploader::Base

	# Include MiniMagick
	include CarrierWave::MiniMagick

	# Storage Type
	storage :file
	# storage :fog

	# Where files will be uploaded
	def store_dir
		"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
	end

	# White List of Safe Extension
	def extension_white_list
		%w(jpg jpeg gif png)
	end
	
	# Hash filenames
	def filename
		"#{secure_token}.#{file.extension}" if original_filename.present?
	end

	protected

	# Secure Token for File Hashing
	def secure_token
		var = :"@#{mounted_as}_secure_token"
		model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.uuid)
	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phcpress-0.10.8 app/uploaders/phcpress/pstimage_uploader.rb