Sha256: b030bf1ce5eba39b9c87118e50b12da5951b2d2136ef09a6f33ab63a42df0d93
Contents?: true
Size: 702 Bytes
Versions: 2
Compression:
Stored size: 702 Bytes
Contents
module Paperclip class DataUriAdapter < StringioAdapter REGEXP = /^data:([-\w]+\/[-\w\+]+);base64,(.*)/ def initialize(target_uri) @target_uri = target_uri cache_current_values @tempfile = copy_to_tempfile end private def cache_current_values self.original_filename = 'base64.txt' data_uri_parts ||= @target_uri.match(REGEXP) || [] @content_type = data_uri_parts[1] || 'text/plain' @target = StringIO.new(Base64.decode64(data_uri_parts[2] || '')) @size = @target.size end end end Paperclip.io_adapters.register Paperclip::DataUriAdapter do |target| String === target && target =~ Paperclip::DataUriAdapter::REGEXP end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
paperclip-3.5.1 | lib/paperclip/io_adapters/data_uri_adapter.rb |
paperclip-3.5.0 | lib/paperclip/io_adapters/data_uri_adapter.rb |