|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2009 the original author or authors. |
| 2 | + * Copyright 2002-2010 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
18 | 18 |
|
19 | 19 | import java.io.IOException;
|
20 | 20 | import java.io.UnsupportedEncodingException;
|
21 |
| -import java.util.Collection; |
| 21 | +import java.nio.charset.Charset; |
22 | 22 | import java.util.HashMap;
|
23 | 23 | import java.util.List;
|
24 | 24 | import java.util.Map;
|
25 |
| -import java.nio.charset.Charset; |
26 | 25 |
|
27 | 26 | import org.apache.commons.fileupload.FileItem;
|
28 | 27 | import org.apache.commons.fileupload.FileItemFactory;
|
|
32 | 31 | import org.apache.commons.logging.LogFactory;
|
33 | 32 |
|
34 | 33 | import org.springframework.core.io.Resource;
|
| 34 | +import org.springframework.http.MediaType; |
35 | 35 | import org.springframework.util.LinkedMultiValueMap;
|
36 | 36 | import org.springframework.util.MultiValueMap;
|
37 | 37 | import org.springframework.util.StringUtils;
|
38 | 38 | import org.springframework.web.multipart.MultipartFile;
|
39 | 39 | import org.springframework.web.util.WebUtils;
|
40 |
| -import org.springframework.http.MediaType; |
41 | 40 |
|
42 | 41 | /**
|
43 | 42 | * Base class for multipart resolvers that use Jakarta Commons FileUpload
|
@@ -271,14 +270,16 @@ protected MultipartParsingResult parseFileItems(List<FileItem> fileItems, String
|
271 | 270 | * @param multipartFiles Collection of MultipartFile instances
|
272 | 271 | * @see org.apache.commons.fileupload.FileItem#delete()
|
273 | 272 | */
|
274 |
| - protected void cleanupFileItems(Collection<MultipartFile> multipartFiles) { |
275 |
| - for (MultipartFile file : multipartFiles) { |
276 |
| - if (file instanceof CommonsMultipartFile) { |
277 |
| - CommonsMultipartFile cmf = (CommonsMultipartFile) file; |
278 |
| - cmf.getFileItem().delete(); |
279 |
| - if (logger.isDebugEnabled()) { |
280 |
| - logger.debug("Cleaning up multipart file [" + cmf.getName() + "] with original filename [" + |
281 |
| - cmf.getOriginalFilename() + "], stored " + cmf.getStorageDescription()); |
| 273 | + protected void cleanupFileItems(MultiValueMap<String, MultipartFile> multipartFiles) { |
| 274 | + for (List<MultipartFile> files : multipartFiles.values()) { |
| 275 | + for (MultipartFile file : files) { |
| 276 | + if (file instanceof CommonsMultipartFile) { |
| 277 | + CommonsMultipartFile cmf = (CommonsMultipartFile) file; |
| 278 | + cmf.getFileItem().delete(); |
| 279 | + if (logger.isDebugEnabled()) { |
| 280 | + logger.debug("Cleaning up multipart file [" + cmf.getName() + "] with original filename [" + |
| 281 | + cmf.getOriginalFilename() + "], stored " + cmf.getStorageDescription()); |
| 282 | + } |
282 | 283 | }
|
283 | 284 | }
|
284 | 285 | }
|
|
0 commit comments