README.md in carrierwave-base64-2.3.5 vs README.md in carrierwave-base64-2.4.0

- old
+ new

@@ -6,11 +6,11 @@ Upload files encoded as base64 to carrierwave. This small gem can be useful for API's that interact with mobile devices. -As of version 2.3.0, this gem requires Ruby 2.0 or higher +This gem requires Ruby 2.0 or higher. ## Installation Add the gem to your Gemfile: @@ -32,21 +32,31 @@ mount_base64_uploader :image, ImageUploader ``` Now you can also upload files by passing an encoded base64 string to the attribute. +## Upload file extension + +The file extension for the uploaded base64 string is identified automatically using the [mime-types](https://github.com/mime-types/ruby-mime-types/) gem and `content_type` from the uploaded string. + +If the required MIME type is not registered, you can add it, using [MIME::Types#add](http://www.rubydoc.info/gems/mime-types/MIME/Types#add-class_method). + ## Setting the file name -To set the file name for the uploaded files, use the `:file_name` option (without extention): +You can set the `file_name` option to a lambda, that will return a filename without an extension, using the model instance: ```ruby -mount_base64_uploader :image, ImageUploader, file_name: 'userpic' +mount_base64_uploader :image, ImageUploader, file_name: -> (u) { u.username } ``` -You can also pass a Proc for the file-name to allow dynamic filenames. +**[DEPRECATED: Settings this option to a string is deprecated, if you still want to set the filename to a fixed string, wrap it in a Proc]** To set the file name for the uploaded files, use the `:file_name` option (without extention): ```ruby -mount_base64_uploader :image, ImageUploader, file_name: -> { "file-#{DateTime.now.to_i}" } +# Deprecated way: +mount_base64_uploader :image, ImageUploader, file_name: 'userpic' + +# New way +mount_base64_uploader :image, ImageUploader, file_name: -> { 'userpic' } ``` ## Data format The string with the encoded data, should be prefixed with Data URI scheme format: