rootstrap / active-storage-base64

Base64 support for ActiveStorage
https://rootstrap.com
MIT License
161 stars 16 forks source link

ArgumentError missing keyword 'io' #28

Closed jcdavison closed 5 years ago

jcdavison commented 5 years ago

Greetings @Ricoch

using

class RequestItem < ApplicationRecord

  include ActiveStorageSupport::SupportForBase64
  has_one_base64_attached :image

  belongs_to :request
  belongs_to :order, required: false
  belongs_to :product_provider, required: false
  belongs_to :product, required: false
  belongs_to :lab
  has_many :approvals
  has_one_attached :sds_pdf

end

I'm running in a web request and receiving below ArgumentError

request_item.image = { data: image , filename: 'image.jpg', content_type: 'image/jpg', identify: false}
ArgumentError: missing keyword: io
from /Users/jd/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/activestorage-5.2.0/app/models/active_storage/blob.rb:60:in `create_after_upload!'

image is

  conn = Faraday.new(:url => 'http://localhost:3000/api/v1/')

  image = Base64.encode64(File.read("vin_di_porto.jpg"))
  body = { 
    request_item: {
      name: 'wineglass',
      quantity: 1,
    },
    request_item_image: image
  }
  res = conn.post do |req|
    req.url 'labs.json'
    req.body = body 
  end

using gems

gem 'rails', '5.2.0'
gem 'active_storage_base64'
gem "aws-sdk-s3", require: false

and in the above error I am running in development

  config.active_storage.service = :amazon

Thoughts on what is causing me this problem ?

Innarticles commented 5 years ago

@jcdavison Were you able to resolve this?

jbzozowski commented 5 years ago

I'd like to know what is causing the 'ArgumentError: missing keyword: io' as well, since I am having the same problem.

jcdavison commented 5 years ago

I ended up reverting to use multipart form data in my upload and my problems went away :)

@Innarticles

Innarticles commented 5 years ago

@jcdavison that means you didn't use base64 image. If that's the case, no need using this gem.

Innarticles commented 5 years ago

Hi, I resolved this problem by supplying my base64 image as "data:image/jpg;base64,iVBORw0KGgo..."

Hope this helps someone