Nicky Manali Nicky Manali - 1 month ago 10
MySQL Question

returning file size = -1 from server in android

I am making an android app in which i am fetching images from server which are stored in mysql database.so i needed the file size before downloading and i am using this code

FileOutputStream fileOutput = new FileOutputStream(file);

InputStream inputStream = urlConnection.getInputStream();
int totalSize = urlConnection.getContentLength();


but always i am getting totalsize =
-1
1.I dont know why this is happening.plz help me to resolve this issue

Answer

Seems the server is not setting Content-Length in the response header.

Comments