backups_controller.rb 883 B

12345678910111213141516171819202122232425262728293031
  1. # frozen_string_literal: true
  2. class BackupsController < ApplicationController
  3. include RoutingHelper
  4. skip_before_action :require_functional!
  5. before_action :authenticate_user!
  6. before_action :set_backup
  7. def download
  8. case Paperclip::Attachment.default_options[:storage]
  9. when :s3, :azure
  10. redirect_to @backup.dump.expiring_url(10), allow_other_host: true
  11. when :fog
  12. if Paperclip::Attachment.default_options.dig(:fog_credentials, :openstack_temp_url_key).present?
  13. redirect_to @backup.dump.expiring_url(Time.now.utc + 10), allow_other_host: true
  14. else
  15. redirect_to full_asset_url(@backup.dump.url), allow_other_host: true
  16. end
  17. when :filesystem
  18. redirect_to full_asset_url(@backup.dump.url), allow_other_host: true
  19. end
  20. end
  21. private
  22. def set_backup
  23. @backup = current_user.backups.find(params[:id])
  24. end
  25. end