Coder Social home page Coder Social logo

Comments (5)

janko avatar janko commented on June 4, 2024 1

Yes, the key specifies the storage name the URL options will be applied to. I see now that this is not clearly documented, I'll push a fix for this.

from shrine.

janko avatar janko commented on June 4, 2024

I couldn't reproduce your issue, the self-contained script below applies the default URL host:

require "shrine"
require "shrine/storage/s3"

Shrine.storages = {
  cache: Shrine::Storage::S3.new(bucket: "cache", stub_responses: true),
  store: Shrine::Storage::S3.new(bucket: "store", stub_responses: true),
}

Shrine.plugin :activerecord

class ImageUploader < Shrine
  plugin :url_options, store: { host: "https://abc123.example.com" }
end

ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.connection.create_table(:photos) { |t| t.text :image_data }

class Photo < ActiveRecord::Base
  include ImageUploader::Attachment(:image)
end

post = Photo.create(image: StringIO.new("foobar"))
post.image_url #=> "https://abc123.example.com/..."

from shrine.

dan avatar dan commented on June 4, 2024

It's the default_storage plugin.

plugin :default_storage, store: :images

With this enabled, the url_options plugin setting is ignored. Is there another/proper way for me to specify this?

from shrine.

dan avatar dan commented on June 4, 2024

Well, this seems to work:

plugin :url_options, images: { host: "https://abc123.example.com" }

from shrine.

dan avatar dan commented on June 4, 2024

Thanks so much for helping me understand my mistake, I appreciate it!

from shrine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.