WebUtilities

class WebUtilities(apiProperties: ApiProperties)

Utility-class revolving around interactions with web-resources.

Author

Griefed

Parameters

apiProperties

API configuration of this instance.

Constructors

Link copied to clipboard
constructor(apiProperties: ApiProperties)

Functions

Link copied to clipboard

Create a HasteBin post from a given text file. The text file provided is read into a string and then passed onto Haste zneix which creates a HasteBin post out of the passed String and returns the URL to the newly created post.

Link copied to clipboard

Create a HasteBin post from a given string. The text provided passed onto Haste zneix which creates a HasteBin post out of the passed String and returns the URL to the newly created post.

Link copied to clipboard
fun downloadAndReplaceFile(fileDestination: File, downloadURL: URL): Boolean

Download the file from the specified URL to the specified destination, replacing the file if it already exists. The destination should end in a valid filename. Any directories up to the specified file will be created.

Link copied to clipboard
fun downloadFile(file: File, downloadURL: URL): Boolean

Download the file from the specified URL to the specified destination. The destination should end in a valid filename. Any directories up to the specified file will be created.

Link copied to clipboard

Get the response of a call to a URL as a string.

Link copied to clipboard

Get the response-code of a call to a URL as an integer.

Link copied to clipboard
fun hasteBinPreChecks(fileToCheck: File): Boolean

Checks the filesize of the given file whether it is smaller or bigger than 10 MB.

Link copied to clipboard

Check the availability of the host of the given URL and whether the URL gives a status code of

Link copied to clipboard

Open the given uri in a browser.

Open the given url in a browser.