fog / fog-backblaze

Integration library for gem fog and Backblaze B2 Cloud Storage
MIT License
19 stars 22 forks source link

no implicit conversion of ActionDispatch::Http::UploadedFile into String #23

Closed paulsizer closed 4 years ago

paulsizer commented 4 years ago

I seem to be getting the following error when submitting my form for my model:

no implicit conversion of ActionDispatch::Http::UploadedFile into String

Some details of my setup are below:

Rails 6.0.2.2 Ruby 2.6.0p0 gem 'fog-backblaze', '~> 0.3.0’ gem 'shrine-fog', '~> 2.0', '>= 2.0.1’ gem 'shrine', '~> 3.2', '>= 3.2.1'

Model

class Show < ApplicationRecord
  include ImageUploader::Attachment(:artwork)
end

Image Uploader

class ImageUploader < Shrine
  plugin :store_dimensions

  Attacher.validate do
    validate_max_size  10*1024*1024
    validate_mime_type %w[image/jpeg image/png]
    validate_extension %w[jpg jpeg png]
  end
end

Shrine.rb

require "shrine"
require "shrine/storage/fog"
require "fog/backblaze"

storeb2 = Fog::Storage.new(
  provider: 'backblaze',
  b2_key_id: ‘###',
  b2_key_token: ‘###',
  b2_bucket_name: ’test',
  b2_bucket_id: ‘###'
)

Shrine.storages[:store] = Shrine::Storage::Fog.new(
  connection: storeb2,
  directory: “test",
)

Shrine.storages[:cache] = Shrine::Storage::Fog.new(
  connection: storeb2,
  directory: “test",
)

Shrine.plugin :activerecord 
Shrine.plugin :cached_attachment_data
Shrine.plugin :restore_cached_data 
Shrine.plugin :validation
Shrine.plugin :validation_helpers

Controller Code Where it is blowing up

def create
  @show = Show.new(show_params)

  if @show.save
    flash[:notice] = "The new show has been added to your account"
    redirect_to @show
  else
     render :new 
  end
end

private

def show_params
  params.require(:show).permit(:title, :artwork)
end

Do you know what this could be?

Paxa commented 4 years ago

Should be fixed by https://github.com/fog/fog-backblaze/commit/3884c0c0b91a66f4abed447e1e1149d9f23c912d

doutatsu commented 3 years ago

I am having a similar problem, except the error is no implicit conversion of Tempfile into String. I am using the setup as here and in the example used from your commit @Paxa, but it doesn't work

doutatsu commented 3 years ago

Actually a clarification. If I use the same example as in the commit, I get no implicit conversion of Rack::Test::UploadedFile into String. If I use remote_url approach from shrine, I get the Tempfile into String error

doutatsu commented 3 years ago

I realised that I need to fetch directly from github, as latest changes are not published in the gem 😄 It also seems to not work with transformations and remote URLs. If I just upload an actual file, as in the example, it'll work (but fail in transformations)