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