Sha256: 85340e87f44248032074b67bce119fd0c701c387cde08eb3ed5c64f479dda437
Contents?: true
Size: 503 Bytes
Versions: 1
Compression:
Stored size: 503 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
paperclip-4.0.0 | lib/paperclip/io_adapters/data_uri_adapter.rb |