Module: Shrine::Plugins::KitheAcceptRemoteUrl::AttacherMethods
- Defined in:
- lib/shrine/plugins/kithe_accept_remote_url.rb
Instance Method Summary collapse
-
#promote(storage: store_key, **options) ⇒ Object
Override to use ‘headers’ key in UploadedFile data for making remote request, when remote_url is being supplied.
Instance Method Details
#promote(storage: store_key, **options) ⇒ Object
Override to use ‘headers’ key in UploadedFile data for making remote request, when remote_url is being supplied.
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/shrine/plugins/kithe_accept_remote_url.rb', line 67 def promote(storage: store_key, **) 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 |