cowinapi / developer.cowin

This group is created to facilitate technical and integration discussions related to cowin platform. API related contents can be obtained at API setu portal https://apisetu.gov.in/public/marketplace/api/cowin
115 stars 30 forks source link

download certificate issue #487

Closed shekharkumar86 closed 3 years ago

shekharkumar86 commented 3 years ago

I am able to get the response from download certificate api but response is binary content data. How can i convert it into pdf file in android. Please help.

/v2/registration/certificate/public/download

shekharkumar86 commented 3 years ago

i have resolve my problem. //using retrofit

val inps = response.body()?.byteStream() var file=File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "${System.currentTimeMillis()}_vacindia.pdf") file.createNewFile() val fos = FileOutputStream(file) var read = 0 val buffer = ByteArray(32768) while (inps?.read(buffer).also { if (it != null) { read = it } }!! > 0) { fos.write(buffer, 0, read) } fos.close() inps?.close()