Sha256: 1a1d9d287647c911f672a13f6281f89f6e442a5ce339285280ba3ac974275fc2
Contents?: true
Size: 1018 Bytes
Versions: 1
Compression:
Stored size: 1018 Bytes
Contents
# encoding: utf-8 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_id = params[:id].to_s.gsub("%C3%B8", "ΓΈ") image_path = "#{Rails.public_path}/#{image_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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_imager-0.0.16 | app/controllers/rails_imager/images_controller.rb |