/** * If any file is created on the disk, delete them all. * Even if this method is not called, the resource will be still cleaned up later by GC. */ public void cleanUp() { for (FileItem item : byName.values()) item.delete(); }
fileItem.delete();
/** * Cleanup the Spring MultipartFiles created during multipart parsing, * potentially holding temporary data on disk. * <p>Deletes the underlying Commons FileItem instances. * @param multipartFiles a Collection of MultipartFile instances * @see org.apache.commons.fileupload.FileItem#delete() */ protected void cleanupFileItems(MultiValueMap<String, MultipartFile> multipartFiles) { for (List<MultipartFile> files : multipartFiles.values()) { for (MultipartFile file : files) { if (file instanceof CommonsMultipartFile) { CommonsMultipartFile cmf = (CommonsMultipartFile) file; cmf.getFileItem().delete(); LogFormatUtils.traceDebug(logger, traceOn -> "Cleaning up part '" + cmf.getName() + "', filename '" + cmf.getOriginalFilename() + "'" + (traceOn ? ", stored " + cmf.getStorageDescription() : "")); } } } }
type = "zip"; } else { item.delete(); registerError(ret, "File type " + contentType + " unrecognized.", resp, 400);
/** * Cleanup the Spring MultipartFiles created during multipart parsing, * potentially holding temporary data on disk. * <p>Deletes the underlying Commons FileItem instances. * @param multipartFiles a Collection of MultipartFile instances * @see org.apache.commons.fileupload.FileItem#delete() */ protected void cleanupFileItems(MultiValueMap<String, MultipartFile> multipartFiles) { for (List<MultipartFile> files : multipartFiles.values()) { for (MultipartFile file : files) { if (file instanceof CommonsMultipartFile) { CommonsMultipartFile cmf = (CommonsMultipartFile) file; cmf.getFileItem().delete(); LogFormatUtils.traceDebug(logger, traceOn -> "Cleaning up part '" + cmf.getName() + "', filename '" + cmf.getOriginalFilename() + "'" + (traceOn ? ", stored " + cmf.getStorageDescription() : "")); } } } }
for (FileItem fileItem : items) { try { fileItem.delete(); } catch (Exception ignored) {
/** * Helper method to test creation of a field when a repository is used. */ public void testInMemoryObject(byte[] testFieldValueBytes, File repository) { FileItem item = createFileItem(testFieldValueBytes, repository); // Check state is as expected assertTrue("Initial: in memory", item.isInMemory()); assertEquals("Initial: size", item.getSize(), testFieldValueBytes.length); compareBytes("Initial", item.get(), testFieldValueBytes); item.delete(); }
/** * Test creation of a field for which the amount of data falls above the * configured threshold. */ @Test public void testAboveThreshold() { // Create the FileItem byte[] testFieldValueBytes = createContentBytes(threshold + 1); FileItem item = createFileItem(testFieldValueBytes); // Check state is as expected assertFalse("Initial: in memory", item.isInMemory()); assertEquals("Initial: size", item.getSize(), testFieldValueBytes.length); compareBytes("Initial", item.get(), testFieldValueBytes); item.delete(); }
@Override public void cleanupMultipart(MultipartRequest request) { if (request != null) { try { MultiValueMap<String, MultipartFile> multipartFiles = request.getMultiFileMap(); for (List<MultipartFile> files : multipartFiles.values()) { for (MultipartFile file : files) { if (file instanceof StandardMultipartFile) { StandardMultipartFile cmf = (StandardMultipartFile)file; cmf.getFileItem().delete(); } } } } catch (Throwable ex) { Log.w(AndServer.TAG, "Failed to perform multipart cleanup for servlet request."); } } }
/** * Deletes temp file from disk */ public void delete() { item.delete(); }
public void cleanup() { item.delete(); } }
/** * Deletes temp file from disk */ public void delete() { item.delete(); }
/** * If any of these files exist, delete them. * * @param tempFiles * The file items to delete. */ protected void deleteTempFiles(List<FileItem> tempFiles) { for (FileItem item : tempFiles) { item.delete(); } }
/** * If any file is created on the disk, delete them all. * Even if this method is not called, the resource will be still cleaned up later by GC. */ public void cleanUp() { for (FileItem item : byName.values()) item.delete(); }
/** * If any file is created on the disk, delete them all. Even if this method * is not called, the resource will be still cleaned up later by GC. */ public void cleanUp() { for (FileItem item : byName.values()) { item.delete(); } } }
/** * If any file is created on the disk, delete them all. * Even if this method is not called, the resource will be still cleaned up later by GC. */ public void cleanUp() { for (FileItem item : byName.values()) item.delete(); } }
@Override public void close() throws IOException { if(keyFile!=null) keyFile.delete(); if(item!=null) item.delete(); } };
public void remove(FileItem item) { if (item != null) { logger.debug("Remove item " + item.getName() + " with name " + item.getFieldName()); map.remove(item.getFieldName()); // Remove temporary stuff item.delete(); } }
@Override protected void respond(AjaxRequestTarget target) { IRequestParameters params = RequestCycle.get().getRequest().getPostParameters(); String fileName = params.getParameterValue("name").toString(); for (Iterator<FileItem> it = fileItems.iterator(); it.hasNext();) { FileItem fileItem = it.next(); if (fileItem.getName().equals(fileName)) { fileItem.delete(); it.remove(); } } }