-
Notifications
You must be signed in to change notification settings - Fork 238
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
Use uploader class for carrierwave #143
base: master
Are you sure you want to change the base?
Use uploader class for carrierwave #143
Conversation
This is a very nice feature, but, what if the user doesn't define any version?. |
https://github.com/bastiaanterhorst/rich/blob/master/lib/rich.rb#L11 |
Yes, sorry, my fault. didn't see that. may I ask you something, are you getting an error with fog when you use amazon s3 as storage?. I'm getting one weird error. |
I don't use fog yet(with rich). Error from amazon or rich code? Show me messages! =) |
Hi, i was about to update my comment, this is what is causing the "fog" problem; it's not fog actually, |
I could find the error I was trying to let you know before, if I don't include version :rich_thumb do
process :resize_to_fit => [100, 100]
end in my custom uploader I get this error: This is also happening when I set a custom version in my uploader |
I change your code to this module DefaultCarrierwaveVersions
Rich.image_styles.each do |name, size|
unless Rich.uploader.constantize.versions.include? name
Rich.uploader.constantize.send :version, name.to_s do
process :resize_to_fit => size.gsub("#", "").split("x").map(&:to_i)
end
end
end
end and now the versions are working (the ones you set in rich initializer and removing the versions from my custom uploader) |
And yet I think, making preview image(rich_thumb) with PaperClip or Carrierwave is not good. We need add to model RichFile column preview, which will not be depend of image_styles and any image uploaders. |
My friend, there's something new that you should change in your commit in order to make it work with fog and your custom uploader. def uri_cache
uri_cache_attribute = read_attribute(:uri_cache)
if uri_cache_attribute.blank?
uris = {}
rich_file.versions.each do |version|
uris[version[0]] = rich_file.url(version[0].to_sym)
end
#manualy add the original size
uris["original"] = rich_file.url
uri_cache_attribute = uris.to_json
rich_file.model.update_attribute(:uri_cache, uri_cache_attribute)
end
uri_cache_attribute
end Please, add a comment to your PR to let know that this pull requests allows amazon S3 as storage too. |
Another thing, you cannot use the same uploader for images and files :/ |
Are we going to be able to use S3 then with this merge? |
yes. the uploader can be configured in order to use S3. |
any direction to this? |
to be honest I don't remember but I'd say that it's exactly how you did it. Set up your backend to carrierwave, set the name of your carrierwave uploader and config your uploader with fog to use S3. Check the code to be sure. |
Ahhh how do you set up the name of the carrierwave uploader in rich. I have an uploader called ImageUploader which uses fog for my other images but how can i get fog to use this as well? |
with the |
tried this |
my friend, I think the correct config is |
that didnt work either. So i set fog as global store but i am now getting this error NoMethodError - undefined method `merge' for false:FalseClass: |
No description provided.