2017-08-12 08:32:15 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-21 17:25:11 -04:00
|
|
|
Rails.application.routes.draw do
|
2018-09-14 10:23:32 -04:00
|
|
|
scope ActiveStorage.routes_prefix do
|
2020-05-11 16:21:58 -04:00
|
|
|
get "/blobs/redirect/:signed_id/*filename" => "active_storage/blobs/redirect#show", as: :rails_service_blob
|
|
|
|
get "/blobs/proxy/:signed_id/*filename" => "active_storage/blobs/proxy#show", as: :rails_service_blob_proxy
|
2020-05-21 10:35:25 -04:00
|
|
|
get "/blobs/:signed_id/*filename" => "active_storage/blobs/redirect#show"
|
2017-07-20 18:33:31 -04:00
|
|
|
|
2020-05-11 16:21:58 -04:00
|
|
|
get "/representations/redirect/:signed_blob_id/:variation_key/*filename" => "active_storage/representations/redirect#show", as: :rails_blob_representation
|
|
|
|
get "/representations/proxy/:signed_blob_id/:variation_key/*filename" => "active_storage/representations/proxy#show", as: :rails_blob_representation_proxy
|
2020-05-21 10:35:25 -04:00
|
|
|
get "/representations/:signed_blob_id/:variation_key/*filename" => "active_storage/representations/redirect#show"
|
2017-07-23 12:05:20 -04:00
|
|
|
|
2018-09-14 10:23:32 -04:00
|
|
|
get "/disk/:encoded_key/*filename" => "active_storage/disk#show", as: :rails_disk_service
|
|
|
|
put "/disk/:encoded_token" => "active_storage/disk#update", as: :update_rails_disk_service
|
|
|
|
post "/direct_uploads" => "active_storage/direct_uploads#create", as: :rails_direct_uploads
|
|
|
|
end
|
2017-07-21 17:25:01 -04:00
|
|
|
|
2018-03-03 15:36:43 -05:00
|
|
|
direct :rails_representation do |representation, options|
|
|
|
|
signed_blob_id = representation.blob.signed_id
|
|
|
|
variation_key = representation.variation.key
|
|
|
|
filename = representation.blob.filename
|
2017-07-20 18:33:31 -04:00
|
|
|
|
2018-03-03 15:36:43 -05:00
|
|
|
route_for(:rails_blob_representation, signed_blob_id, variation_key, filename, options)
|
2017-07-20 18:33:31 -04:00
|
|
|
end
|
2017-07-21 17:25:01 -04:00
|
|
|
|
2020-05-11 16:21:58 -04:00
|
|
|
resolve("ActiveStorage::Variant") { |variant, options| route_for(ActiveStorage.resolve_model_to_route, variant, options) }
|
|
|
|
resolve("ActiveStorage::VariantWithRecord") { |variant, options| route_for(ActiveStorage.resolve_model_to_route, variant, options) }
|
|
|
|
resolve("ActiveStorage::Preview") { |preview, options| route_for(ActiveStorage.resolve_model_to_route, preview, options) }
|
2017-09-28 16:43:37 -04:00
|
|
|
|
2018-09-14 10:23:32 -04:00
|
|
|
direct :rails_blob do |blob, options|
|
|
|
|
route_for(:rails_service_blob, blob.signed_id, blob.filename, options)
|
|
|
|
end
|
|
|
|
|
2020-05-11 16:21:58 -04:00
|
|
|
resolve("ActiveStorage::Blob") { |blob, options| route_for(ActiveStorage.resolve_model_to_route, blob, options) }
|
|
|
|
resolve("ActiveStorage::Attachment") { |attachment, options| route_for(ActiveStorage.resolve_model_to_route, attachment.blob, options) }
|
|
|
|
|
|
|
|
direct :rails_storage_proxy do |model, options|
|
|
|
|
if model.respond_to?(:signed_id)
|
|
|
|
route_for(
|
|
|
|
:rails_service_blob_proxy,
|
|
|
|
model.signed_id,
|
|
|
|
model.filename,
|
|
|
|
options
|
|
|
|
)
|
|
|
|
else
|
|
|
|
signed_blob_id = model.blob.signed_id
|
|
|
|
variation_key = model.variation.key
|
|
|
|
filename = model.blob.filename
|
|
|
|
|
|
|
|
route_for(
|
|
|
|
:rails_blob_representation_proxy,
|
|
|
|
signed_blob_id,
|
|
|
|
variation_key,
|
|
|
|
filename,
|
|
|
|
options
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
direct :rails_storage_redirect do |model, options|
|
|
|
|
if model.respond_to?(:signed_id)
|
|
|
|
route_for(
|
|
|
|
:rails_service_blob,
|
|
|
|
model.signed_id,
|
|
|
|
model.filename,
|
|
|
|
options
|
|
|
|
)
|
|
|
|
else
|
|
|
|
signed_blob_id = model.blob.signed_id
|
|
|
|
variation_key = model.variation.key
|
|
|
|
filename = model.blob.filename
|
|
|
|
|
|
|
|
route_for(
|
|
|
|
:rails_blob_representation,
|
|
|
|
signed_blob_id,
|
|
|
|
variation_key,
|
|
|
|
filename,
|
|
|
|
options
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2019-07-12 15:30:28 -04:00
|
|
|
end if ActiveStorage.draw_routes
|