Module: Shrine::Plugins::RemoteUrl
- Defined in:
- lib/shrine/plugins/remote_url.rb
Overview
Documentation can be found on shrinerb.com/docs/plugins/remote_url
Defined Under Namespace
Modules: AttacherMethods, AttachmentMethods, ClassMethods Classes: DownloadError
Constant Summary collapse
- LOG_SUBSCRIBER =
-> (event) do Shrine.logger.info "Remote URL (#{event.duration}ms) – #{{ remote_url: event[:remote_url], download_options: event[:download_options], uploader: event[:uploader], }.inspect}" end
- DOWNLOADER =
-> (url, **) { Down.download(url, **) }
Class Method Summary collapse
- .configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts) ⇒ Object
- .load_dependencies(uploader) ⇒ Object
Class Method Details
.configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/shrine/plugins/remote_url.rb', line 25 def self.configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts) uploader.opts[:remote_url] ||= { downloader: DOWNLOADER } uploader.opts[:remote_url].merge!(opts) unless uploader.opts[:remote_url].key?(:max_size) fail Error, "The :max_size option is required for remote_url plugin" end # instrumentation plugin integration uploader.subscribe(:remote_url, &log_subscriber) if uploader.respond_to?(:subscribe) end |
.load_dependencies(uploader) ⇒ Object
21 22 23 |
# File 'lib/shrine/plugins/remote_url.rb', line 21 def self.load_dependencies(uploader, *) uploader.plugin :validation end |