cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

mediamodel url not working after updating existing media(excel file)

Former Member
0 Likes
578

Hi I was reading an excel file form media ,which is uploaded through storefront and stored in media. After reading that file based on my requirement i was adding new columns(like error logs) in existing excel file.After that I was accessing that mediaurl using media model.getURL to download ,but its not working and download started and getting cancelled after few seconds.

 final File excel = new File(filePath);
         final FileInputStream file = new FileInputStream(excel);
 
         //    final FileInputStream file = new FileInputStream(new File(filePath));
         final XSSFWorkbook workbook = new XSSFWorkbook(file);
 
         // Get first sheet from the workbook
         final XSSFSheet abMappingSheet = workbook.getSheetAt(0);
 for (final HashMap.Entry entry : errorData.entrySet())
         {
             final int cellNo = abMappingSheet.getRow(cellCount + 2).getLastCellNum();
             final XSSFCell errorCell = abMappingSheet.getRow(cellCount + 2).createCell(cellNo);
             errorCell.setCellValue(entry.getKey() + "=" + entry.getValue());
             cellCount++;
         }
     final FileOutputStream outFile = new FileOutputStream(excel, false);
         workbook.write(outFile);
         outFile.close();
         workbook.close();
         file.close();

Accepted Solutions (0)

Answers (0)