001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.web.multipart; 018 019import java.util.Iterator; 020import java.util.List; 021import java.util.Map; 022 023import org.springframework.util.MultiValueMap; 024 025/** 026 * This interface defines the multipart request access operations 027 * that are exposed for actual multipart requests. It is extended 028 * by {@link MultipartHttpServletRequest} and the Portlet 029 * {@link org.springframework.web.portlet.multipart.MultipartActionRequest}. 030 * 031 * @author Juergen Hoeller 032 * @author Arjen Poutsma 033 * @since 2.5.2 034 */ 035public interface MultipartRequest { 036 037 /** 038 * Return an {@link java.util.Iterator} of String objects containing the 039 * parameter names of the multipart files contained in this request. These 040 * are the field names of the form (like with normal parameters), not the 041 * original file names. 042 * @return the names of the files 043 */ 044 Iterator<String> getFileNames(); 045 046 /** 047 * Return the contents plus description of an uploaded file in this request, 048 * or {@code null} if it does not exist. 049 * @param name a String specifying the parameter name of the multipart file 050 * @return the uploaded content in the form of a {@link MultipartFile} object 051 */ 052 MultipartFile getFile(String name); 053 054 /** 055 * Return the contents plus description of uploaded files in this request, 056 * or an empty list if it does not exist. 057 * @param name a String specifying the parameter name of the multipart file 058 * @return the uploaded content in the form of a {@link MultipartFile} list 059 * @since 3.0 060 */ 061 List<MultipartFile> getFiles(String name); 062 063 /** 064 * Return a {@link java.util.Map} of the multipart files contained in this request. 065 * @return a map containing the parameter names as keys, and the 066 * {@link MultipartFile} objects as values 067 */ 068 Map<String, MultipartFile> getFileMap(); 069 070 /** 071 * Return a {@link MultiValueMap} of the multipart files contained in this request. 072 * @return a map containing the parameter names as keys, and a list of 073 * {@link MultipartFile} objects as values 074 * @since 3.0 075 */ 076 MultiValueMap<String, MultipartFile> getMultiFileMap(); 077 078 /** 079 * Determine the content type of the specified request part. 080 * @param paramOrFileName the name of the part 081 * @return the associated content type, or {@code null} if not defined 082 * @since 3.1 083 */ 084 String getMultipartContentType(String paramOrFileName); 085 086}