Nicky Manali Nicky Manali - 1 year ago 93
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 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.I dont know why this is happening.plz help me to resolve this issue

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download