<commit_before># encoding: utf-8

module Carto
  module StorageOptions
    class S3
      def self.conf
        Cartodb.get_config_if_present(:aws, 's3')
      end

      def initialize(bucket_name)
        @bucket_name = bucket_name

        AWS::config(self.class.conf)
      end

      def upload(namespace, file)
        filename = Pathname.new(file.path).basename.to_s
        mime_type = MIME::Types.type_for(filename).first.to_s
        identifier = File.join(namespace, filename)

        asset = bucket.objects[identifier]
        asset.write(file: file, content_type: mime_type)

        [identifier, asset.url_for(:public_read).to_s]
      end

      def remove(path)
        bucket.objects[path].delete
      end

      def bucket
        @bucket ||= s3.buckets[@bucket_name]
      end
<commit_msg>fix s3<commit_after># encoding: utf-8

module Carto
  module StorageOptions
    class S3
      def self.conf
        Cartodb.get_config_if_present(:aws, 's3')
      end

      def initialize(bucket_name)
        @bucket_name = bucket_name

        AWS::config(self.class.conf)
      end

      def upload(namespace, file)
        filename = Pathname.new(file.path).basename.to_s
        mime_type = MIME::Types.type_for(filename).first.to_s
        identifier = File.join(namespace, filename)

        asset = bucket.objects[identifier]
        asset.write(file: file, content_type: mime_type, acl: :public_read)

        [identifier, asset.public_url(secure: true).to_s]
      end

      def remove(path)
        bucket.objects[path].delete
      end

      def bucket
        @bucket ||= s3.buckets[@bucket_name]
      end

{'fraction_non_alphanumeric': 0.09847094801223241, 'fraction_numerical': 0.005504587155963303, 'mean_word_length': 2.429769392033543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2245825', 'n_tokens_mistral': 525, 'n_tokens_neox': 506, 'n_words': 100}