Skip to content

Commit

Permalink
Fix bops_uploads route scope
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew White <andrew.white@unboxed.co>
  • Loading branch information
benjamineskola and pixeltrix committed Jan 28, 2025
1 parent 6c09634 commit 901315d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions engines/bops_uploads/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,25 @@
end

Rails.application.routes.draw do
extend BopsCore::Routing

namespace :bops_uploads, path: nil do
local_authority_subdomain do
get "/files/:key", to: "files#show", as: "file"
end

uploads_subdomain do
get "/:key", to: "blobs#show", as: "upload"
end
end

direct :uploaded_file do |blob, options|
next "" if blob.blank?

if Rails.configuration.use_signed_cookies
bops_uploads.file_url(blob.key)
route_for(:bops_uploads_file, blob.key, options)
else
bops_uploads.upload_url(blob.key, host: Rails.configuration.uploads_base_url)
route_for(:bops_uploads_upload, blob.key, options.merge(host: Rails.configuration.uploads_base_url))
end
end

Expand All @@ -29,4 +41,5 @@
resolve("ActiveStorage::Preview") { |preview, options| route_for(:uploaded_file, preview, options) }
resolve("ActiveStorage::VariantWithRecord") { |variant, options| route_for(:uploaded_file, variant, options) }
resolve("ActiveStorage::Variant") { |variant, options| route_for(:uploaded_file, variant, options) }
resolve("Document") { |document, options| route_for(:uploaded_file, document.file, options) }
end

0 comments on commit 901315d

Please sign in to comment.