backups_controller.rb 926 B

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