def perform
      if @file_size < SINGLE_UPLOAD_MAX
        resource = "#{DEFAULT_RESOURCE}#{@bucket}"
        response = upload(resource, File.read(@file_path))
        response.headers['location'][0]
      else
        response = init_chunked_upload
        bytes_per_chunk_size = response.headers['x-ton-min-chunk-size'][0].to_i
        location = response.headers['location'][0]

        bytes_read = 0
        chunk_bytes = bytes_per_chunk_size * DEFAULT_CHUNK_SIZE
        File.open(@file_path) do |file|
          while bytes = file.read(chunk_bytes)
            bytes_start = bytes_read
            bytes_read += bytes.size
            upload_chunk(location, bytes, bytes_start, bytes_read) do |res|
              # Determines the chunk bytes based on response times
              response_time = res.headers['x-response-time'][0].to_f
              response_based_chunk_size =
                (DEFAULT_CHUNK_SIZE * (RESPONSE_TIME_MAX / response_time)).to_i
              next_chunk_size = [DEFAULT_CHUNK_SIZE, [1, response_based_chunk_size].max].min
              chunk_bytes = bytes_per_chunk_size * next_chunk_size
            end
          end
        end

        location.split('?')[0]
      end
    end
def perform
      if @file_size < SINGLE_UPLOAD_MAX
        resource = "#{DEFAULT_RESOURCE}#{@bucket}"
        response = upload(resource, File.read(@file_path))
        response.headers['location'][0]
      else
        response = init_chunked_upload
        bytes_per_chunk_size = response.headers['x-ton-min-chunk-size'][0].to_i
        location = response.headers['location'][0]

        bytes_read = 0
        chunk_bytes = bytes_per_chunk_size * DEFAULT_CHUNK_SIZE
        File.open(@file_path) do |file|
          while bytes = file.read(chunk_bytes)
            bytes_start = bytes_read
            bytes_read += bytes.size
            upload_chunk(location, bytes, bytes_start, bytes_read) do |res|
              # Determines the chunk bytes based on response times
              response_time = res.headers['x-response-time'][0].to_f
              response_based_chunk_size =
                (DEFAULT_CHUNK_SIZE * (RESPONSE_TIME_MAX / response_time)).to_i
              next_chunk_size = [DEFAULT_CHUNK_SIZE, [1, response_based_chunk_size].max].min
              chunk_bytes = bytes_per_chunk_size * next_chunk_size
            end
          end
        end

        location.split('?')[0]
      end
    end
Creates a new TONUpload object instance.

 @example
   request = TONUpload.new(client, '/path/to/file')

 @param client [Client] The Client object instance.
 @param file_path [String] The path to the file to be uploaded.

 @since 0.3.0

 @return [TONUpload] The TONUpload request instance.
 Executes the current TONUpload object.

 @example
   request = TONUpload.new(client, '/path/to/file')
   request.perform

 @since 0.3.0

 @return [String] The upload location provided by the TON API.