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

Rails quickstart fails with invalid URL #8

Open
titusjohnson opened this issue Apr 28, 2020 · 0 comments
Open

Rails quickstart fails with invalid URL #8

titusjohnson opened this issue Apr 28, 2020 · 0 comments

Comments

@titusjohnson
Copy link

titusjohnson commented Apr 28, 2020

Following the readme for Shrine and Shrine-Cloudinary to get some simple image uploads going fails with Cloudinary producing an invalid URL when attempting to move the image from cache to storage.

require "shrine"
require "cloudinary"
require "shrine/storage/cloudinary"

Cloudinary.config(
  cloud_name: ENV.fetch('CLOUDINARY_NAME'),
  api_key:    ENV.fetch('CLOUDINARY_API_KEY'),
  api_secret: ENV.fetch('CLOUDINARY_API_SECRET'),
)

Shrine.storages = {
  cache: Shrine::Storage::Cloudinary.new(prefix: "dev/cashe"),
  store: Shrine::Storage::Cloudinary.new(prefix: "dev/site"),
}

Shrine.plugin :activerecord           # loads Active Record integration
Shrine.plugin :cached_attachment_data # enables retaining cached file across form redisplays
Shrine.plugin :restore_cached_data    # extracts metadata for assigned cached files

Form:

= form_for @photo, url: location_photos_path(@location) do |f|
  = f.hidden_field :image, value: @photo.cached_image_data
  %p
    = f.label :image, 'Select Image'
    = f.file_field :image
  %p
    = f.label :primary do
      = f.check_box :primary
      Primary? (shown first)
  = f.submit

Error:

CloudinaryException in PhotosController#create
Error in loading https:///image/upload/v1/dev/cashe/307b71836c1af10884968e59aa325add.jpg - Invalid URI

Stacktrace:

cloudinary (1.13.2) lib/cloudinary/uploader.rb:342:in `block in call_api'
rest-client (2.1.0) lib/restclient/request.rb:834:in `process_result'
rest-client (2.1.0) lib/restclient/request.rb:743:in `block in transmit'
/Users/titusjohnson/.rbenv/versions/2.6.3/lib/ruby/2.6.0/net/http.rb:920:in `start'
rest-client (2.1.0) lib/restclient/request.rb:727:in `transmit'
rest-client (2.1.0) lib/restclient/request.rb:163:in `execute'
rest-client (2.1.0) lib/restclient/request.rb:63:in `execute'
cloudinary (1.13.2) lib/cloudinary/uploader.rb:329:in `call_api'
cloudinary (1.13.2) lib/cloudinary/uploader.rb:76:in `upload'
shrine-cloudinary (1.1.1) lib/shrine/storage/cloudinary.rb:181:in `public_send'
shrine-cloudinary (1.1.1) lib/shrine/storage/cloudinary.rb:181:in `method_missing'
shrine-cloudinary (1.1.1) lib/shrine/storage/cloudinary.rb:96:in `store'
shrine-cloudinary (1.1.1) lib/shrine/storage/cloudinary.rb:24:in `upload'
shrine (3.2.1) lib/shrine.rb:245:in `_upload'
shrine (3.2.1) lib/shrine.rb:210:in `upload'
shrine (3.2.1) lib/shrine.rb:108:in `upload'
shrine (3.2.1) lib/shrine/attacher.rb:182:in `upload'
shrine (3.2.1) lib/shrine/attacher.rb:171:in `promote'
shrine (3.2.1) lib/shrine/attacher.rb:162:in `promote_cached'
shrine (3.2.1) lib/shrine/attacher.rb:145:in `finalize'
shrine (3.2.1) lib/shrine/plugins/activerecord.rb:90:in `activerecord_after_save'
...(snip)

Note the lack of a cloudinary domain name in the temp file URI. The temp files do appear on Cloudinary, I can see & manipulate them via the UI.

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

1 participant