Module: Readymade::Model::ApiAttachable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/readymade/model/api_attachable.rb
Instance Method Summary collapse
- #api_attachable_format?(attachment_file) ⇒ Boolean
- #api_attachment_to_uploaded(attachment_file) ⇒ Object
Instance Method Details
#api_attachable_format?(attachment_file) ⇒ Boolean
44 45 46 |
# File 'lib/readymade/model/api_attachable.rb', line 44 def api_attachable_format?() .respond_to?(:key?) && .key?('base64') && .key?('filename') end |
#api_attachment_to_uploaded(attachment_file) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/readymade/model/api_attachable.rb', line 48 def () ActionDispatch::Http::UploadedFile.new( tempfile: Tempfile.new([:filename]).tap do |tf| tf.binmode tf.write(Base64.decode64([:base64].split('base64,')[-1])) end, filename: [:filename], type: Mime::Type.lookup_by_extension(File.extname([:filename])[1..]).to_s ) end |