Taficloud has been published on Jitpack and would be available on MavenCentral.

Add it in your root build.gradle at the end of repositories:

1

Add Jitpack

2

Add the dependency

dependencies {
    implementation 'com.github.magnavisio.TafiCloudLib:taficloud-jvm:$Version'
}

Usage

Initialize the library

To use the library, initialize it with your API key:

import taficloud.Taficloud

val tafiCloud = Taficloud("YOUR_API_KEY")

Upload a file

Upload a file to Taficloud:

val file = File("path/to/file")
val response = taficloud.upload(file.readBytes(), fileName = file.name, folder = "samples")
println(response)

Upload Base64

Upload a base64 encoded file:

val base64 = "base64 string"
val response = taficloud.uploadBase64(base64, "samples")
println(response)

Upload Multiple files

val files = mapOf(
File("path/to/file1").readBytes() to "file1",
File("path/to/file2").readBytes() to "file2"
)
val response = taficloud.upload(files)
println(response)

Download File

val response = taficloud.downloadFile("YOUR_MEDIA_KEY")
val dir = File("src/main/resources/downloads")
dir.mkdirs()
val output = File(dir, "/download.png")
output.createNewFile()
output.writeBytes(response)
println(response)

Compress Image

val file = File("path/to/file")
val response = taficloud.compressPng(
file = file.readBytes(),
fileName = file.name,
compressionLevel = 5,
adaptiveFiltering = false,
palette = false,
quality = 50,
effort = 5
)
val dir = File("src/main/resources/downloads")
dir.mkdirs()å
val output = File(dir, "/coolio_compressed.png")
output.createNewFile()
output.writeBytes(response)
println(response)