Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Versions full_filename bug #2127

Closed
miguelpeniche opened this issue Feb 17, 2017 · 2 comments
Closed

Versions full_filename bug #2127

miguelpeniche opened this issue Feb 17, 2017 · 2 comments

Comments

@miguelpeniche
Copy link

The next code saves the correct versions to user.avatar, but it uploads only jpg's to S3...

class UserAvatarUploader < CarrierWave::Uploader::Base

	include CarrierWave::MiniMagick

	version :large do
		process resize_to_fit: [ 600, 600 ], convert: :jpg
		def full_filename (for_file = model.avatar.file)
			"large_#{secure_token}.jpg"
		end
	end

	version :small do
		process resize_to_fill: [ 216, 216 ], convert: :jpg
		def full_filename (for_file = model.avatar.file)
			"small_#{secure_token}.jpg"
		end
	end

	version :thumb do
		process resize_to_fill: [ 80, 80 ], convert: :png
		def full_filename (for_file = model.avatar.file)
			"thumb_#{secure_token}.png"
		end
	end

	version :tiny do
		process resize_to_fill: [ 50, 50 ], convert: :png
		def full_filename (for_file = model.avatar.file)
			"tiny_#{secure_token}.png"
		end
	end

	def filename
		"#{secure_token}.#{file.extension}" if original_filename.present?
	end

	protected

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

end
@mshibuya
Copy link
Member

mshibuya commented Jan 3, 2023

@miguelpeniche Could you elaborate this more? What does

but it uploads only jpg's to S3...

mean? While I could confirm #2125 and #2126, this seemed to work fine.

@mshibuya
Copy link
Member

mshibuya commented Mar 6, 2023

Stale, please let me know on update.

@mshibuya mshibuya closed this as not planned Won't fix, can't repro, duplicate, stale Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants