Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
paulsizer opened this issue Apr 30, 2020 · 2 comments

Comments

@paulsizer
Copy link

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 1010241024
    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?

@janko
Copy link
Member

janko commented Apr 30, 2020

Either fog or fog-backblaze could be requiring file content to be given on upload instead of a file object. Either that or an actual File instance is required, which can be obtained using Shrine.with_file.

@paulsizer
Copy link
Author

@janko Thanks for your reply, apologises as it’s not really something I am really clued up on. Is this something that I can alter my side through the uploader or some other way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants