<commit_before>class ContentBlobsController < ApplicationController

  before_filter :find_and_authorize_associated_asset, :only=>[:get_pdf, :view_pdf_content, :download]
  before_filter :find_and_authorize_content_blob, :only=>[:get_pdf, :view_pdf_content, :download]
  before_filter :set_asset_version, :only=>[:get_pdf, :download]

  include Seek::AssetsCommon
  include Seek::UploadHandling::ExamineUrl
  include Seek::ContentBlobCommon

  def view_pdf_content
    #param code is used for temporary link
    @pdf_url = polymorphic_path([@asset,@content_blob], :action => 'download',:intent=>:inline_view, :format => 'pdf', :code => params[:code])
    respond_to do |format|
      format.html { render :layout=>false }
    end
  end

  def examine_url
    #check content type and size
    url = params[:data_url]
    begin
      code = check_url_response_code(url)
      if code == 200
        process_view_for_successful_url(url)
      else
        handle_non_200_response(code)
      end
    rescue Exception=>e
      handle_exception_response(e)
    end
  end

  def get_pdf
    if @content_blob.file_exists?
      begin
        pdf_or_convert
      rescue Exception => e
        raise(e)
      end<commit_msg>ContentBlobCommon is implicitly included by AssetsCommon<commit_after>class ContentBlobsController < ApplicationController

  before_filter :find_and_authorize_associated_asset, :only=>[:get_pdf, :view_pdf_content, :download]
  before_filter :find_and_authorize_content_blob, :only=>[:get_pdf, :view_pdf_content, :download]
  before_filter :set_asset_version, :only=>[:get_pdf, :download]

  include Seek::AssetsCommon
  include Seek::UploadHandling::ExamineUrl

  def view_pdf_content
    #param code is used for temporary link
    @pdf_url = polymorphic_path([@asset,@content_blob], :action => 'download',:intent=>:inline_view, :format => 'pdf', :code => params[:code])
    respond_to do |format|
      format.html { render :layout=>false }
    end
  end

  def examine_url
    #check content type and size
    url = params[:data_url]
    begin
      code = check_url_response_code(url)
      if code == 200
        process_view_for_successful_url(url)
      else
        handle_non_200_response(code)
      end
    rescue Exception=>e
      handle_exception_response(e)
    end
  end

  def get_pdf
    if @content_blob.file_exists?
      begin
        pdf_or_convert
      rescue Exception => e
        raise(e)
      end
{'fraction_non_alphanumeric': 0.09176566980745596, 'fraction_numerical': 0.004916018025399427, 'mean_word_length': 3.9036144578313254, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2878886', 'n_tokens_mistral': 780, 'n_tokens_neox': 756, 'n_words': 168}