scinote-web/app/controllers/zip_exports_controller.rb

28 lines
680 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-03-21 23:15:11 +08:00
class ZipExportsController < ApplicationController
before_action :load_var, only: %i(download download_export_all_zip)
# File download permissions are now managed by ActiveStorage controllers
2017-03-21 23:15:11 +08:00
def download
if !@zip_export.zip_file.attached?
render_404
2017-03-23 22:45:02 +08:00
else
redirect_to rails_blob_path(@zip_export.zip_file, disposition: 'attachment')
2017-03-23 22:45:02 +08:00
end
2017-03-21 23:15:11 +08:00
end
def download_export_all_zip
download
end
2017-03-29 15:32:23 +08:00
def file_expired; end
2017-03-27 16:38:28 +08:00
2017-03-21 23:15:11 +08:00
private
def load_var
@zip_export = current_user.zip_exports.find_by_id(params[:id])
redirect_to(file_expired_url, status: 301) and return unless @zip_export&.zip_file&.exists?
end
2017-03-21 23:15:11 +08:00
end