use uuid blobs controller

pull/217/head
Pete Matsyburka 2 years ago
parent 71c61fc4b3
commit 78e9e66cb0

@ -0,0 +1,35 @@
# frozen_string_literal: true
module Api
class ActiveStorageBlobsProxyLegacyController < ApiBaseController
include ActiveStorage::Streaming
skip_before_action :authenticate_user!
skip_authorization_check
def show
Rollbar.info('Blob legacy') if defined?(Rollbar)
return render json: { error: 'Not authenticated' }, status: :unauthorized unless current_user
blob = ActiveStorage::Blob.find_signed!(params[:signed_blob_id] || params[:signed_id])
if blob.attachments.none? { |a| a.record.account.id == current_user.account_id }
Rollbar.error("Blob account not found: #{blob.id}") if defined?(Rollbar)
return head :not_found
end
if request.headers['Range'].present?
send_blob_byte_range_data blob, request.headers['Range']
else
http_cache_forever public: true do
response.headers['Accept-Ranges'] = 'bytes'
response.headers['Content-Length'] = blob.byte_size.to_s
send_blob_stream blob, disposition: params[:disposition]
end
end
end
end
end

@ -6,7 +6,7 @@
</a> </a>
<div class="space-x-3 flex items-center"> <div class="space-x-3 flex items-center">
<% if @submission.audit_trail.present? %> <% if @submission.audit_trail.present? %>
<a href="<%= rails_blob_path(@submission.audit_trail) %>" class="white-button" target="_blank"> <a href="<%= ActiveStorage::Blob.proxy_url(@submission.audit_trail.blob) %>" class="white-button" target="_blank">
<%= svg_icon('external_link', class: 'w-6 h-6') %> <%= svg_icon('external_link', class: 'w-6 h-6') %>
<span class="hidden md:inline"> <span class="hidden md:inline">
Audit Log Audit Log

@ -22,6 +22,8 @@ module DocuSeal
config.active_storage.routes_prefix = '' config.active_storage.routes_prefix = ''
config.active_storage.draw_routes = ENV['MULTITENANT'] != 'true'
config.i18n.available_locales = %i[en en-US en-GB es-ES fr-FR pt-PT de-DE es it de fr pl uk cs pt he nl] config.i18n.available_locales = %i[en en-US en-GB es-ES fr-FR pt-PT de-DE es it de fr pl uk cs pt he nl]
config.i18n.fallbacks = [:en] config.i18n.fallbacks = [:en]

@ -113,7 +113,7 @@ Devise.setup do |config|
# This can reduce the time taken to boot the app but if your application # This can reduce the time taken to boot the app but if your application
# requires the Devise mappings to be loaded during boot time the application # requires the Devise mappings to be loaded during boot time the application
# won't boot properly. # won't boot properly.
# config.reload_routes = true config.reload_routes = false
# ==> Configuration for :database_authenticatable # ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 12. If # For bcrypt, this is the cost for hashing the password and defaults to 12. If

@ -82,9 +82,19 @@ Rails.application.routes.draw do
resources :submissions_export, only: %i[index new] resources :submissions_export, only: %i[index new]
end end
resources :preview_document_page, only: %i[show], path: '/preview/:signed_uuid' resources :preview_document_page, only: %i[show], path: '/preview/:signed_uuid'
resource :blobs_proxy, only: %i[show], path: '/blobs_proxy/:signed_uuid/*filename(.:format)', resource :blobs_proxy, only: %i[show], path: '/blobs_proxy/:signed_uuid/*filename',
controller: 'api/active_storage_blobs_proxy' controller: 'api/active_storage_blobs_proxy'
if Docuseal.multitenant?
resource :blobs_proxy_legacy, only: %i[show],
path: '/blobs/proxy/:signed_id/*filename',
controller: 'api/active_storage_blobs_proxy_legacy',
as: :rails_blob
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
resources :start_form, only: %i[show update], path: 'd', param: 'slug' do resources :start_form, only: %i[show update], path: 'd', param: 'slug' do
get :completed get :completed
end end

Loading…
Cancel
Save