$(document).on("click", "#video_submit_button", (event) => {
  const input = $("#video_file");

  if (input[0].files.length > 0) {
    event.preventDefault();

    const bucket = input.data("aws-bucket");
    const awsAccessKeyId = input.data("aws-access-key-id");
    const signerUrl = input.data("signer-url");

    const uploader = Evaporate.create({
      logging: false,
      signerUrl: signerUrl,
      aws_key: awsAccessKeyId,
      bucket: bucket,
      cloudfront: false,
      computeContentMd5: true,
      cryptoMd5Method: (d) => btoa(SparkMD5.ArrayBuffer.hash(d, true)),
      cryptoHexEncodedHash256: sha256,
    });

    const submitButton = $(event.target);
    submitButton.prop('disabled', true);

    const allFilesCompleted = () => {
      input.value = '';
      $("#video_form").submit();
    }
    uploadFile(input[0].files[0], uploader, input, allFilesCompleted)
  }
});
