<commit_before>module S3Multipart
  class UploadsController < ApplicationController

    def create
      begin
        upload = Upload.create(params)
        upload.execute_callback(:begin, session)
        response = upload.to_json
      rescue FileTypeError, FileSizeError => e
        response = {error: e.message}
      rescue => e
        logger.error "EXC: #{e.message}"
        airbrake(e, params)
        response = { error: t("s3_multipart.errors.create") }
      ensure
        render :json => response
      end
    end

    def update
      return complete_upload if params[:parts]
      return sign_batch if params[:content_lengths]
      return sign_part if params[:content_length]
    end

    private

      def sign_batch
        begin
          response = Upload.sign_batch(params)
        rescue => e
          logger.error "EXC: #{e.message}"
          airbrake(e, params)
          response = {error: t("s3_multipart.errors.update")}
        ensure<commit_msg>Permit all params<commit_after>module S3Multipart
  class UploadsController < ApplicationController

    def create
      begin
        upload = Upload.create(permitted_params)
        upload.execute_callback(:begin, session)
        response = upload.to_json
      rescue FileTypeError, FileSizeError => e
        response = {error: e.message}
      rescue => e
        logger.error "EXC: #{e.message}"
        airbrake(e, params)
        response = { error: t("s3_multipart.errors.create") }
      ensure
        render :json => response
      end
    end

    def update
      return complete_upload if params[:parts]
      return sign_batch if params[:content_lengths]
      return sign_part if params[:content_length]
    end

    private

      def permitted_params
        params.permit!
      end

      def sign_batch
        begin
          response = Upload.sign_batch(params)
        rescue => e
          logger.error "EXC: #{e.message}"
          airbrake(e, params)
          response = {error: t("s3_multipart.errors.update")}
        ensure
{'fraction_non_alphanumeric': 0.08435507601765571, 'fraction_numerical': 0.0029426189308484553, 'mean_word_length': 2.2227488151658767, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '6339360', 'n_tokens_mistral': 576, 'n_tokens_neox': 572, 'n_words': 143}