Skip to content

Commit

Permalink
manual rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Oct 22, 2024
1 parent 04dc09d commit 8dd32aa
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,18 @@ public static Boolean downloadFile(String fileUrl, String saveDir) {
int responseCode = httpConn.getResponseCode();

if (responseCode == HttpURLConnection.HTTP_OK) {
String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
String fileName = "";
String disposition = httpConn.getHeaderField("Content-Disposition");

if (disposition != null) {
int index = disposition.indexOf("filename=");
if (index > 0) {
fileName = disposition.substring(index + 10, disposition.length() - 1);
}
} else {
fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
}

InputStream inputStream = httpConn.getInputStream();
String saveFilePath = saveDir + File.separator + fileName;

Expand Down

0 comments on commit 8dd32aa

Please sign in to comment.