From a3a494c3a278dd347c2aa2142312d33f53c9370b Mon Sep 17 00:00:00 2001 From: mlorb Date: Tue, 5 Dec 2017 17:55:09 +0100 Subject: [PATCH] fix banana: remove dead code which strangely reappeared, probably with some rebasing --- app/controllers/assets_controller.rb | 62 ---------------------------- config/routes.rb | 1 - 2 files changed, 63 deletions(-) diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index d6b0ce7bc..3f5dd9a2a 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -11,31 +11,8 @@ class AssetsController < ApplicationController before_action :load_vars before_action :check_read_permission, except: :file_present - before_action :load_vars, except: :signature - before_action :check_read_permission, except: [:signature, :file_present] before_action :check_edit_permission, only: :edit - # Validates asset and then generates S3 upload posts, because - # otherwise untracked files could be uploaded to S3 - def signature - respond_to do |format| - format.json { - asset = Asset.new(asset_params) - if asset.valid? - posts = generate_upload_posts asset - render json: { - posts: posts - } - else - render json: { - status: 'error', - errors: asset.errors - }, status: :bad_request - end - } - end - end - def file_present respond_to do |format| format.json do @@ -160,45 +137,6 @@ class AssetsController < ApplicationController end end - def generate_upload_posts(asset) - posts = [] - s3_post = S3_BUCKET.presigned_post( - key: asset.file.path[1..-1], - success_action_status: '201', - acl: 'private', - storage_class: "STANDARD", - content_length_range: 1..Constants::FILE_MAX_SIZE_MB.megabytes, - content_type: asset.file_content_type - ) - posts.push({ - url: s3_post.url, - fields: s3_post.fields - }) - - condition = %r{^image/#{Regexp.union(Constants::WHITELISTED_IMAGE_TYPES)}} - - if condition === asset.file_content_type - asset.file.options[:styles].each do |style, option| - s3_post = S3_BUCKET.presigned_post( - key: asset.file.path(style)[1..-1], - success_action_status: '201', - acl: 'public-read', - storage_class: "REDUCED_REDUNDANCY", - content_length_range: 1..Constants::FILE_MAX_SIZE_MB.megabytes, - content_type: asset.file_content_type - ) - posts.push({ - url: s3_post.url, - fields: s3_post.fields, - style_option: option, - mime_type: asset.file_content_type - }) - end - end - - posts - end - def append_wd_params(url) wd_params = '' params.keys.select { |i| i[/^wd.*/] }.each do |wd| diff --git a/config/routes.rb b/config/routes.rb index 2cbacf401..b4a69855d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -484,7 +484,6 @@ Rails.application.routes.draw do get 'files/:id/preview', to: 'assets#preview', as: 'preview_asset' get 'files/:id/view', to: 'assets#view', as: 'view_asset' get 'files/:id/edit', to: 'assets#edit', as: 'edit_asset' - post 'asset_signature' => 'assets#signature' devise_scope :user do get 'avatar/:id/:style' => 'users/registrations#avatar', as: 'avatar'