WebUtilities

expect class WebUtilities

Utility-class revolving around interactions with web-resources.

Author

Griefed

actual 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
expect fun createHasteBinFromFile(textFile: File): String

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.

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
expect 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
expect 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
expect fun getResponseAsString(url: URL): String

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

Link copied to clipboard
expect fun getResponseCode(url: URL): Int

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

Link copied to clipboard
expect 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
expect fun isReachable(url: URL): Boolean

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

Link copied to clipboard
expect fun openLinkInBrowser(url: URL)

Open the given url in a browser.

Open the given uri in a browser.