Changeset 25053 for main/trunk/greenstone3/src/java/org/greenstone
- Timestamp:
- 2012-02-07T13:54:40+13:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java
r24993 r25053 438 438 } 439 439 440 441 440 FileChannel source = null; 442 441 FileChannel destination = null; … … 484 483 String href = null; 485 484 String rl = null; 486 String[] nameval = new String[2]; // Reuse it for memory efficiency purposes487 485 488 486 for (int i = 0; i < query_arr.length; i++) … … 506 504 { 507 505 rl = query_arr[i].substring(query_arr[i].indexOf("=") + 1, query_arr[i].length()); 506 } 507 } 508 509 for (String arg : query_arr) 510 { 511 if (arg.startsWith("downloadFile")) 512 { 513 int index = arg.indexOf("="); 514 if (index > -1 && index < arg.length() - 1) 515 { 516 String fileLocation = arg.substring(index + 1); 517 File fileToGet = new File(GlobalProperties.getGSDL3Home() + File.separator + fileLocation); 518 519 if (fileToGet.exists()) 520 { 521 response.setContentType("application/octet-stream"); 522 response.addHeader("Content-Disposition","attachment;filename=" + fileToGet.getName()); 523 FileInputStream fis = new FileInputStream(fileToGet); 524 ServletOutputStream sos = response.getOutputStream(); 525 526 byte[] buffer = new byte[4096]; 527 int len; 528 while ((len = fis.read(buffer)) != -1) 529 { 530 sos.write(buffer, 0, len); 531 } 532 sos.flush(); 533 fis.close(); 534 sos.close(); 535 536 return; 537 } 538 } 508 539 } 509 540 }
Note:
See TracChangeset
for help on using the changeset viewer.