Sha256: 3627f17e06254b884d46efe3ef7c73375cddd50aabae5b79234fae3908970692

Contents?: true

Size: 506 Bytes

Versions: 26

Compression:

Stored size: 506 Bytes

Contents

module Paperclip
  class DataUriAdapter < StringioAdapter

    REGEXP = /\Adata:([-\w]+\/[-\w\+\.]+)?;base64,(.*)/m

    def initialize(target_uri)
      super(extract_target(target_uri))
    end

    private

    def extract_target(uri)
      data_uri_parts = uri.match(REGEXP) || []
      StringIO.new(Base64.decode64(data_uri_parts[2] || ''))
    end

  end
end

Paperclip.io_adapters.register Paperclip::DataUriAdapter do |target|
  String === target && target =~ Paperclip::DataUriAdapter::REGEXP
end

Version data entries

26 entries across 24 versions & 6 rubygems

Version Path
kt-paperclip-4.4.0 lib/paperclip/io_adapters/data_uri_adapter.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paperclip-5.1.0/lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-5.1.0 lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-5.0.0 lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-4.3.7 lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip_jk-5.0.0.beta2 lib/paperclip/io_adapters/data_uri_adapter.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/paperclip-4.3.6/lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-5.0.0.beta2 lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-5.0.0.beta1 lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-4.3.6 lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-4.3.5 lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-4.3.4 lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-4.3.3 lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-4.3.2 lib/paperclip/io_adapters/data_uri_adapter.rb
paperclip-4.3.1 lib/paperclip/io_adapters/data_uri_adapter.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/paperclip-4.2.4/lib/paperclip/io_adapters/data_uri_adapter.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/paperclip-4.2.4/lib/paperclip/io_adapters/data_uri_adapter.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.2/lib/paperclip/io_adapters/data_uri_adapter.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.3/lib/paperclip/io_adapters/data_uri_adapter.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.4/lib/paperclip/io_adapters/data_uri_adapter.rb