module Shrine::Plugins::KitheAcceptRemoteUrl::AttacherMethods
Public Instance Methods
promote(storage: store_key, **options)
click to toggle source
Override to use 'headers' key in UploadedFile data for making remote request, when remote_url is being supplied.
Calls superclass method
# File lib/shrine/plugins/kithe_accept_remote_url.rb, line 67 def promote(storage: store_key, **options) if file.storage_key.to_s == STORAGE_KEY.to_s && file.data.dig("metadata", METADATA_KEY) # instead of having Shrine "open" the file itself, we'll "open" it ourselves, so # we can add supplied headers. Due to the beauty of design of `down` and `shrine-url`, # and lazy opening, they'll end up using what we already opened. This approach # suggested by Janko. # https://groups.google.com/d/msg/ruby-shrine/SbeGujDa_k8/PeSGwpl9BAAJ file.open(headers: file.data.dig("metadata", METADATA_KEY)) end super end