<commit_before>class ImagesController < ApplicationController
  before_filter :find, :only => [:show, :decode]

  def show
    respond_to do |format|
      format.html {}
      format.json {
        render json: {
          url: render_image_url(@image)
        }, status: :ok
      }
    end
  end

  def new
    @image = Image.new
  end

  def create
    @image = Image.new(image_params)

    # TODO: Since the Data URI too large and is being saved to provide a
    # non-transient state at GET URL time, the database size will diverge.
    # If this module becomes popular, a line should be placed here to
    # wipe out model objects that are too old to matter.

    respond_to do |format|
      if @image.save        
        format.html { redirect_to @image, notice: 'Image was successfully created.' }
        format.json {
          render json: {
            url: render_image_url(@image)
          }, status: :created
        }
      else
        format.html { render action: "new" }
        format.json { render json: @image.errors, status: :unprocessable_entity }
      end
    end
  end

  def decode
    # Render as a real image.
    send_data @image.decode, :type => "image", :disposition => 'inline'
  end

  private

  def find
    @image = Image.find_by_token(params[:id])<commit_msg>Standardize mime type<commit_after>class ImagesController < ApplicationController
  before_filter :find, :only => [:show, :decode]

  def show
    respond_to do |format|
      format.html {}
      format.json {
        render json: {
          url: render_image_url(@image)
        }, status: :ok
      }
    end
  end

  def new
    @image = Image.new
  end

  def create
    @image = Image.new(image_params)

    # TODO: Since the Data URI too large and is being saved to provide a
    # non-transient state at GET URL time, the database size will diverge.
    # If this module becomes popular, a line should be placed here to
    # wipe out model objects that are too old to matter. Alternatively,
    # the database cost should be handled.

    respond_to do |format|
      if @image.save        
        format.html { redirect_to @image, notice: 'Image was successfully created.' }
        format.json {
          render json: {
            url: render_image_url(@image)
          }, status: :created
        }
      else
        format.html { render action: "new" }
        format.json { render json: @image.errors, status: :unprocessable_entity }
      end
    end
  end

  def decode
    # Render as a real image.
    send_data @image.decode, :type => "image/png", :disposition => 'inline'
  end

  private

  def find
    @image = Image.find_by_token(params[:id])
{'fraction_non_alphanumeric': 0.087509349289454, 'fraction_numerical': 0.0, 'mean_word_length': 2.2822085889570554, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3381342', 'n_tokens_mistral': 786, 'n_tokens_neox': 768, 'n_words': 272}