The S3 class is calling URI.encode which is removed in Ruby 3. By providing a URI module within the S3 class makes the S3 code call that module instead.