001/* 002 * Copyright 2002-2016 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.lang.Nullable; 024import org.springframework.util.MultiValueMap; 025 026/** 027 * This interface defines the multipart request access operations that are exposed 028 * for actual multipart requests. It is extended by {@link MultipartHttpServletRequest}. 029 * 030 * @author Juergen Hoeller 031 * @author Arjen Poutsma 032 * @since 2.5.2 033 */ 034public interface MultipartRequest { 035 036 /** 037 * Return an {@link java.util.Iterator} of String objects containing the 038 * parameter names of the multipart files contained in this request. These 039 * are the field names of the form (like with normal parameters), not the 040 * original file names. 041 * @return the names of the files 042 */ 043 Iterator<String> getFileNames(); 044 045 /** 046 * Return the contents plus description of an uploaded file in this request, 047 * or {@code null} if it does not exist. 048 * @param name a String specifying the parameter name of the multipart file 049 * @return the uploaded content in the form of a {@link MultipartFile} object 050 */ 051 @Nullable 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 @Nullable 085 String getMultipartContentType(String paramOrFileName); 086 087}