Class: Admin::AndroidAssetsController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/android_assets_controller.rb

Overview

typed: ignore frozen_string_literal: true

Constant Summary

Constants inherited from BaseController

BaseController::INTERNAL_SERVER_ERROR_MESSAGE

Instance Method Summary collapse

Methods inherited from BaseController

#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from AdminHelper

#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?

Methods included from UpdateLocaleConcern

#setup_locale

Methods inherited from ApplicationController

#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=

Methods included from ControllerHelpers

#check_boolean_param, #get_banners, #inventory_params, #reservation_params

Instance Method Details

#showObject



5
6
7
8
9
10
11
# File 'app/controllers/admin/android_assets_controller.rb', line 5

def show
  @file = if File.exists?(asset_file)
            asset_file.read
          else
            'No file'
          end
end

#updateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/android_assets_controller.rb', line 13

def update
  File.open(asset_file.to_s, 'wb') do |f|
    f.write(params.require(:document).read)
    f.close
  end

  filename = 'assetlinks.json'
  file_path = asset_file.to_s.freeze
  destination_file = "#{Rails.env}_#{filename}".freeze

  s3 = Aws::S3::Resource.new(region: Figaro.env.aws_region!)
  target_obj = s3.bucket(Figaro.env.AWS_DOCS_BUCKET!).object(destination_file)
  target_obj.upload_file(file_path)
  redirect_back fallback_location: back_fallback_location
end