Hi in the below code I am getting response in byte array .Now I am sending response and download and store into file .
But file not stored any where
val byteArrayRequest = ByteArrayRequest(
Request.Method.POST,
url,
js,
{ response ->
// Handle the byte array response here
Log.d(“volley”,”Response:${response}”)
writeBytesAsPdf(response)
},
{ error ->
Log.d(“volley”,”Error:${error.message}”)
}
)
private fun writeBytesAsPdf(bytes : ByteArray) {
val path = applicationContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
Log.d(“volley”,”Path:${path}”)
var file = File.createTempFile(“report”,”.pdf”, path)
var os = FileOutputStream(file);
os.write(bytes);
os.close();
}
file to be downlaoded in particular path
jyothihayathi g is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.