Sha256: de62b1920780deb319f644f3f37d1b0af00828c7e33870e47e6db6774d1bd6f9
Contents?: true
Size: 944 Bytes
Versions: 3
Compression:
Stored size: 944 Bytes
Contents
require_dependency "rails_imager/application_controller" class RailsImager::ImagesController < ApplicationController def show rimger = RailsImager::ImageHandler.new image_params = params[:image] || {} # Check for invalid parameters. image_params.each do |key, val| raise ArgumentError, "Invalid parameter: '#{key}'." unless RailsImager::ImageHandler::PARAMS_ARGS.map{ |param| param.to_s }.include?(key) end image_path = "#{Rails.public_path}/#{params[:id]}" image_path = File.realpath(image_path) validate_path(image_path) rimger.handle( :controller => self, :fpath => image_path, :params => image_params ) end private def validate_path(image_path) raise "No such file: '#{image_path}'." unless File.exists?(image_path) raise "Image wasn't in the public folder: '#{image_path}'." unless image_path.start_with?(Rails.public_path.to_s) end end
Version data entries
3 entries across 3 versions & 1 rubygems