<commit_before>require "securerandom"
require "openssl"

module FormalistDemo
  class Application < Rodakase::Application
    route "uploads" do |r|
      r.on "presign" do
        r.post do
          secret_key = FormalistDemo::Container.config.options.attache_secret_key
          uuid = SecureRandom.uuid
          expiration = (Time.now + 60*60*3).to_i # 3 hours from now

          {
            uuid: uuid,
            expiration: expiration,
            hmac: OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), secret_key, "#{uuid}#{expiration}"),
          }
        end
      end
    end
  end
end<commit_msg>Return the upload URL in the presign response<commit_after>require "securerandom"
require "openssl"

module FormalistDemo
  class Application < Rodakase::Application
    route "uploads" do |r|
      r.on "presign" do
        r.post do
          attache_host = FormalistDemo::Container.config.options.attache_host
          secret_key = FormalistDemo::Container.config.options.attache_secret_key
          uuid = SecureRandom.uuid
          expiration = (Time.now + 60*60*3).to_i # 3 hours from now

          {
            url: "#{attache_host}/upload",
            uuid: uuid,
            expiration: expiration,
            hmac: OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), secret_key, "#{uuid}#{expiration}"),
          }
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10337401292175162, 'fraction_numerical': 0.010050251256281407, 'mean_word_length': 2.375302663438257, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5248510', 'n_tokens_mistral': 447, 'n_tokens_neox': 423, 'n_words': 94}