001/*002 * Copyright 2002-2018 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 at007 *008 * https://www.apache.org/licenses/LICENSE-2.0009 *010 * Unless required by applicable law or agreed to in writing, software011 * 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 and014 * limitations under the License.015 */016017package org.springframework.web.multipart;018019import java.io.File;020import java.io.IOException;021import java.io.InputStream;022import java.nio.file.Files;023import java.nio.file.Path;024025import org.springframework.core.io.InputStreamSource;026import org.springframework.core.io.Resource;027import org.springframework.lang.Nullable;028import org.springframework.util.FileCopyUtils;029030/**031 * A representation of an uploaded file received in a multipart request.032 *033 * <p>The file contents are either stored in memory or temporarily on disk.034 * In either case, the user is responsible for copying file contents to a035 * session-level or persistent store as and if desired. The temporary storage036 * will be cleared at the end of request processing.037 *038 * @author Juergen Hoeller039 * @author Trevor D. Cook040 * @since 29.09.2003041 * @see org.springframework.web.multipart.MultipartHttpServletRequest042 * @see org.springframework.web.multipart.MultipartResolver043 */044public interface MultipartFile extends InputStreamSource {045046 /**047 * Return the name of the parameter in the multipart form.048 * @return the name of the parameter (never {@code null} or empty)049 */050 String getName();051052 /**053 * Return the original filename in the client's filesystem.054 * <p>This may contain path information depending on the browser used,055 * but it typically will not with any other than Opera.056 * @return the original filename, or the empty String if no file has been chosen057 * in the multipart form, or {@code null} if not defined or not available058 * @see org.apache.commons.fileupload.FileItem#getName()059 * @see org.springframework.web.multipart.commons.CommonsMultipartFile#setPreserveFilename060 */061 @Nullable062 String getOriginalFilename();063064 /**065 * Return the content type of the file.066 * @return the content type, or {@code null} if not defined067 * (or no file has been chosen in the multipart form)068 */069 @Nullable070 String getContentType();071072 /**073 * Return whether the uploaded file is empty, that is, either no file has074 * been chosen in the multipart form or the chosen file has no content.075 */