Android Integration

Minimal OkHttp client. callTimeout is 300s — upscale is a slow synchronous call.

1. JSON (image URL)

val body = JSONObject().put("image_url", imageUrl).toString()
    .toRequestBody("application/json".toMediaType())
val req = Request.Builder().url("$base/upscale").post(body).build()

2. Multipart (file upload)

val multipart = MultipartBody.Builder()
    .setType(MultipartBody.FORM)
    .addFormDataPart("file", "upload", bytes.toRequestBody(type.toMediaType()))
    .build()
val req = Request.Builder().url("$base/upscale").post(multipart).build()

3. Parse response

http.newCall(req).execute().use { resp ->
    val json = JSONObject(resp.body!!.string())
    if (json.optString("status") != "success")
        throw IllegalStateException(json.optString("message"))
    val resultUrl = json.getJSONObject("data").getString("result_url")
}

Notes

Full demo client: android/ in the repo.

Result