Foros de discusión
How to download a file from HTTPS url
Logu R, modificado hace 7 años.
How to download a file from HTTPS url
New Member Mensajes: 10 Fecha de incorporación: 15/05/15 Mensajes recientes
How to download a file from HTTPS server using Java. Am getting , am getting HTTPS Response Code : 401, can someone assist on this.
Olaf Kock, modificado hace 7 años.
RE: How to download a file from HTTPS url
Liferay Legend Mensajes: 6403 Fecha de incorporación: 23/09/08 Mensajes recientes
HTTP 401 means "Unauthorized". If that doesn't help you: We have no clue what system you're requesting data from. That means nobody can tell you how to authenticate and authorize without more information
Logu R, modificado hace 7 años.
RE: How to download a file from HTTPS url
New Member Mensajes: 10 Fecha de incorporación: 15/05/15 Mensajes recientes
Thank you for the reply.
Now, i able to pass the authentication and able to downlaod the file also.
But the problem is not able to view the file, i mean files get downloaded with 3 kb but actual size is 260 kb.
Please find the code below
url = new URL(fileURL);
con = url.openConnection();
con.setRequestProperty ("Authorization", "Basic " + loginPassword);
InputStream is = con.getInputStream();
OutputStream os = new FileOutputStream(saveDir);
while ((i = is.read()) != -1) {
os.write(BUFFER_SIZE,0,i);
//System.out.println("file downloaded");
}
Now, i able to pass the authentication and able to downlaod the file also.
But the problem is not able to view the file, i mean files get downloaded with 3 kb but actual size is 260 kb.
Please find the code below
url = new URL(fileURL);
con = url.openConnection();
con.setRequestProperty ("Authorization", "Basic " + loginPassword);
InputStream is = con.getInputStream();
OutputStream os = new FileOutputStream(saveDir);
while ((i = is.read()) != -1) {
os.write(BUFFER_SIZE,0,i);
//System.out.println("file downloaded");
}