Carrierwave plugin that allows create image from data uri
Add this line to your application's Gemfile:
gem 'carrierwave-data-uri'
And then execute:
$ bundle
Or install it yourself as:
$ gem install carrierwave-data-uri
class User < ActiveRecord::Base
mount_uploader :avatar, AvatarUploader
end
Then we can create image from data
user = User.find 123
user.avatar_data_uri = 'data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP////8AAP///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=='
user.save
Optionally, to customize the file name, specify the #{column}_data_filename
attribute before the #{column}_data_uri
attribute.
user = User.find 123
user.avatar_data_filename = 'somefile.jpg'
user.avatar_data_uri = 'data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP////8AAP///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=='
user.save
- Fork it ( https://github.com/[my-github-username]/carrierwave-data-uri/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request