掲示板
How to download a file from HTTPS url
7年前 に Logu R によって更新されました。
How to download a file from HTTPS url
New Member 投稿: 10 参加年月日: 15/05/15 最新の投稿
How to download a file from HTTPS server using Java. Am getting , am getting HTTPS Response Code : 401, can someone assist on this.
7年前 に Olaf Kock によって更新されました。
RE: How to download a file from HTTPS url
Liferay Legend 投稿: 6396 参加年月日: 08/09/23 最新の投稿
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
7年前 に Logu R によって更新されました。
RE: How to download a file from HTTPS url
New Member 投稿: 10 参加年月日: 15/05/15 最新の投稿
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");
}